Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required ARGs #904

Closed
vladaionescu opened this issue Apr 1, 2021 · 2 comments
Closed

Required ARGs #904

vladaionescu opened this issue Apr 1, 2021 · 2 comments
Labels
good first issue Good for newcomers hacktoberfest type:enhancement Small feature requests / adjustments

Comments

@vladaionescu
Copy link
Member

Some UDCs (or even targets) could benefit from strictly required ARGs - ARGs that must be passed in, in order for the command (or target) to work.

This helps eliminate cases where the user is chasing their tail trying to figure out what's wrong when an ARG is unexpectedly set to "" when declared as ARG something and no value is provided on the call itself.

Sytanx suggestion:

ARG --required something

Required ARGs can never have a default value.

CC @jazzdan

@vladaionescu vladaionescu added the type:enhancement Small feature requests / adjustments label Apr 1, 2021
@alexcb alexcb added the good first issue Good for newcomers label Jul 12, 2021
@alexcb
Copy link
Collaborator

alexcb commented Jul 12, 2021

This might be a good first issue if anyone wants to take it on. We would need a new struct for ARG options under https://github.com/earthly/earthly/blob/main/earthfile2llb/flags.go

then, under func (i *Interpreter) handleArg(ctx context.Context, cmd spec.Command) error {, one would have to reference the struct to parse the opts. then if the required flag is set, check the value is not empty.

alexcb pushed a commit that referenced this issue Oct 21, 2021
* Implement Required ARGs #904

* File cannot have default value for --required args

* Allow optional flag for ARG in earthfile syntax

* Error if build-arg not provided for required ARG

Minimal behavior verification test: https://asciinema.org/a/441110

* Add feature test and update ARG docs

* Implement Required ARGs #904

* File cannot have default value for --required args

* Allow optional flag for ARG in earthfile syntax

* Error if build-arg not provided for required ARG

Minimal behavior verification test: https://asciinema.org/a/441110

* Add feature test and update ARG docs

* Add test that args are required, move file after rebase

* Update required-args.earth

Remove double newline, add newline at end of required-args.earth for linter
@alexcb
Copy link
Collaborator

alexcb commented Dec 3, 2021

this has been released and is available under v0.6.0.

@alexcb alexcb closed this as completed Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers hacktoberfest type:enhancement Small feature requests / adjustments
Projects
None yet
Development

No branches or pull requests

2 participants