Cobra: Positional Args

Created on 28 Jan 2016  路  3Comments  路  Source: spf13/cobra

Is there a way to use positional arguments? I read through the docs, but I'm not seeing it.

I do see an example in the README:

git clone URL --bare

but I can't find a way to do this where you describe the positional args for a command.

arelib kinenhancement

Most helpful comment

I believe you just are supposed to use a PreRun command to grab/parse those arguments as needed (those which are not flags).

All 3 comments

One of the advantages is that uses POSIX style flags where they can be placed anywhere vs go's default behavior of using only positional arguments. You can create a flag that only works for one command but it is not restricted to a certain position.

I believe you just are supposed to use a PreRun command to grab/parse those arguments as needed (those which are not flags).

Take a look at #395

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rogercoll picture rogercoll  路  5Comments

groenborg picture groenborg  路  5Comments

andygrunwald picture andygrunwald  路  6Comments

phanirithvij picture phanirithvij  路  5Comments

jjzcru picture jjzcru  路  3Comments