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

Arguments from file example ? #28

Closed
dreampuf opened this issue Mar 10, 2015 · 10 comments
Closed

Arguments from file example ? #28

dreampuf opened this issue Mar 10, 2015 · 10 comments
Assignees

Comments

@dreampuf
Copy link

I didn't found about the case. Could somebody bring me one? Thanks

@alecthomas
Copy link
Owner

It's simply @filename where there is one argument/flag per line. Perhaps the documentation could use some expansion though.

@alecthomas
Copy link
Owner

And use kingpin.ParseWithFileExpansion() instead of kingpin.Parse() to expand automatically.

@dreampuf
Copy link
Author

@alecthomas Thank you.

# cat config
127.0.0.1
8084

one more question, is that passable to using named arguments ? e.g.

$ cat config
host=127.0.0.1
port=8084

@alecthomas alecthomas self-assigned this Mar 18, 2015
@alecthomas
Copy link
Owner

If by named arguments you mean flags, then yes:

--host=127.0.0.1
--port=8084

If you're talking about positional arguments, then no it does not support naming.

@dreampuf
Copy link
Author

Thank you !

@swill
Copy link

swill commented Oct 20, 2016

Even with this, there is no example for how to actually use a config file. Can someone post a CLI example which uses a config file?

@alecthomas
Copy link
Owner

$ cat flags
--some-flag
--some-other-flag=some arg
$ myapp @flags

@swill
Copy link

swill commented Oct 21, 2016

Thanks @alecthomas. :)

I tried this in combination with command line entries and I got the following:

$ cat flags
--some-flag
--some-other-flag=some arg
$ myapp command --pass="xyz" @flags

I got:

$ myapp command --pass="xyz" @flags
panic: runtime error: slice bounds out of range

If I use the @flags, does that mean I can't use the CLI as well?

@alecthomas
Copy link
Owner

This is a known issue (#148). @ support is not great :\

@swill
Copy link

swill commented Oct 21, 2016

Ahh. Ok. I had not seen that issue. Thanks.

I am able to get it working now if put all commands and subcommands in the file, but not if I add anything in the command line arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants