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

Forwarding arguments? #87

Open
tonyb983 opened this issue Nov 2, 2021 · 1 comment
Open

Forwarding arguments? #87

tonyb983 opened this issue Nov 2, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@tonyb983
Copy link

tonyb983 commented Nov 2, 2021

I'm not sure if this feature would be useful or necessary at all, and honestly this may just stem from my bash inexperience, but I'm having trouble forwarding (if this is the correct expression) arguments to a command that is run by mask.

For simplicity sake, say you are building a binary with cmake and attempting to run the output:

Binary usage is such:
$ ./HelloWorld -n <NAME> -l <LANG>

My mask script looks like this:

## standalone

> Builds and runs the standalone executable (cli) portion of the project

**OPTIONS**
* run
    * flags: -r --run
    * type: boolean
    * desc: Run the standalone executable after building

* args
    * flags: -a --args
    * type: string
    * desc: The args to pass to the executable when it is run (flag will be ignored if run is not also passed). If not provided the default will be '--help'.

```bash
INPUT_ARGS=${args:-"--help"}
cmake -S standalone -B build/standalone
cmake --build build/standalone

[[ "$run" == "true" ]] && ./build/standalone/HelloWorld $INPUT_ARGS
\```
(^ Ignore this backslash, it was the only way I could get this block to close)

But I'm getting errors from Mask regarding unexpected arguments (-n flag):

$ mask standalone -r -a "-n Tony"
error: Found argument '-n' which wasn't expected, or isn't valid in this context

USAGE:
    mask standalone --args <args> --run

For more information try --help

Please let me know if I'm doing something wrong or if this is indeed expected behavior, and whether there can be option to forward remaining args "inside" the mask command.

Edit: Sorry for the edit, I fat fingered control + enter to submit this too soon.
Edit2: I'm bad at formatting.

@jacobdeichert
Copy link
Owner

Hey @tonyb983, it appears you've found a bug with our argument parser!

I was testing this using the cmd block below to find out what was going on:

INPUT_ARGS=${args:-"--help"}
[[ "$run" == "true" ]] && echo "$INPUT_ARGS"

When running mask standalone -r --args "-" it succeeds and prints -.

However, when running mask standalone -r --args "-X" using any character where X is located, then I get the same error as you:

error: Found argument '-X' which wasn't expected, or isn't valid in this context

This is because our cli args parser (clap) seems to be confusing it for an argument even though it's wrapped in quotes.

I also tried adding a space after the quote and before the dash: mask standalone -r --args " -X". This actually works! You might be able to use this as a workaround in the meantime until we find a fix for this.

As for a real fix, we might be able to workaround that bug, but it's probably worth trying to update clap first and maybe taking a look at their documentation for an option we can use to allow/ignore dashed args it doesn't know about.

@jacobdeichert jacobdeichert added the bug Something isn't working label Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants