question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assume arguments provided _after_ the .cake script (when provided) to be "remaining arguments"

See original GitHub issue

This is closely related to #3279.

Background

The Cake runner supports a number of arguments, such --version to display the version of the runner, or --debug to launch the script in debug mode.

However, this make it impossible for these names to be used as arguments in Cake build scripts. For example, if one wanted to use the argument version as an input to the build script:

var version = Argument<string>("version");

And then run Cake:

dotnet cake --version=1.2.3

They would receive an error: Flags cannot be assigned a value

Workaround

The current workaround is to use the “remaining arguments” feature when using one of these “reserved” argument names:

dotnet cake -- --version=1.2.3

Proposal

This issue intends to make the necessary updates to - only when a .cake file is provided as an argument - to assume that any arguments after the .cake file to be considered as “remaining arguments” instead of Cake runner arguments.

In other words: Consider that all arguments before the .cake filename to be arguments targeted at the Cake runner, and all arguments after the .cake filename to be targeted at the build script:

dotnet cake (cake-args) filename.cake (build-args)
Command-line Expected result
dotnet cake --version Display Cake version (as it is today)
dotnet cake --version=1.2.3 Error: Flags cannot be assigned a value (unless #3279 is implemented)
dotnet cake build.cake --version=1.2.3 Run build script and set the version argument to 1.2.3
dotnet cake --version=1.2.3 build.cake Error: Flags cannot be assigned a value (unless #3279 is implemented)

This should work for all Cake runner arguments.

image


Related:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
FrankRay78commented, Apr 8, 2023

Sounds good @augustoproiete, I hadn’t thought about using a warning to prepare for the future transition. Can you assign this issue to me again and I will implement it?

1reaction
augustoproietecommented, Apr 8, 2023

Hey @FrankRay78 I like your idea of implementing a new BuildCommand that would allow us to ship this new behavior in a minor release of Cake as soon as it’s ready, document it, and give some time for people to try it it, and eventually we can replace the DefaultCommand with this new one, on a major release of Cake.

I also would suggest we update the DefaultCommand to analyze the arguments and detect any Cake-specific arguments passed after a .cake file (if any), and emit a warning to the user, so that they can adjust their build scripts.

e.g.

dotnet cake --tree frank.cake --target=pack
OK / No warning

dotnet cake frank.cake --tree --target=pack
Warning: Cake will soon require Cake arguments to be passed before the cake build script file.
e.g. instead of
> dotnet cake frank.cake --tree --target=pack
should be
> dotnet cake --tree frank.cake --target=pack
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cake - Reference - Arguments
Gets all arguments with the specific name and throws if the argument is missing. Determines whether or not the specified argument exist.
Read more >
cakebuild - Pass multiple parameters/arguments to target
I am going to assume that you are using the latest bootstrapper file, which is available from here:.
Read more >
Working with functions in Python - Desira Wijesundara - Medium
The output comes in the form of; first two default values being replaced with the provided parameters(in green) and the rest of the...
Read more >
Shells, Tasks & Console Tools - 2.x
The CakePHP console provides a framework for creating shell scripts. ... property contains an array of all the positional arguments provided to a...
Read more >
Adding arguments and options to your Bash scripts
Bash uses a tool called positional parameters to provide a means of entering data into a Bash program when it is invoked from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found