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

Is there a way to escape flag input? #1025

Closed
shairozan opened this issue Jan 31, 2020 · 6 comments
Closed

Is there a way to escape flag input? #1025

shairozan opened this issue Jan 31, 2020 · 6 comments
Labels
kind/support Questions, supporting users, etc.

Comments

@shairozan
Copy link

shairozan commented Jan 31, 2020

Let's say I have a flag called app_options. I want to basically take whatever raw string is provided there and use it to hand to a binary underneath my application.

Ergo if the CLI app I'm calling is do_the_thing, I want to pass the options from app_options to do_the_thing.

Ie
do_the_thing [app_options]

specifying --app_options "-maxlim=0" only yields a value of 0 for the app_options flag as if the rest of the string had been captured as a flag itself.

Is there a way to specify an unescaped or unparsed string such that the above would pass the entirety of maxlim=0 into the cobra flag?

@jharshman jharshman added the kind/support Questions, supporting users, etc. label Mar 30, 2020
@github-actions
Copy link

This issue is being marked as stale due to a long period of inactivity

@fulviodenza
Copy link

Is there any update about this issue?
I'm having the same trouble, I described it here https://stackoverflow.com/questions/70146280/cannot-insert-dash-in-cobra-parameters

@fulviodenza
Copy link

Found a solution, the user will need to add a "--" to the command

@marckhouzam
Copy link
Collaborator

You may also be interested in the Interspersed option of pflag: https://github.com/spf13/pflag/blob/d5e0c0615acee7028e1e2740a11102313be88de1/flag.go#L1208

@marckhouzam
Copy link
Collaborator

There's an explanation of the interspersed option in this issue #1307 (comment)

@johnSchnake
Copy link
Collaborator

Sounds like this got resolved. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/support Questions, supporting users, etc.
Projects
None yet
Development

No branches or pull requests

5 participants