Skip to content

Optional arguments *before" required arguments? #524

Answered by DannyBen
codevogel asked this question in Q&A
Discussion options

You must be logged in to vote

No, this is not supported, but there is an elegant solution if you are willing to consider a different (and more common) usage pattern.

Using optional positional arguments before required positional arguments (i.e. mycli [ALIAS] PATH is bad form in my opinion.
I do not know of any command line utility that does that, and if there is, it is a very small minority. Using such a syntax requires counting the arguments to determine if the first one is ALIAS or PATH.

Now, if I understand you correctly, you want to accomplish this:

  1. Have tmt ALIAS run something that is associated with the alias
  2. Have some intuitive way of adding a new alias from the command line, with required path and optional al…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@codevogel
Comment options

@DannyBen
Comment options

@codevogel
Comment options

@DannyBen
Comment options

Answer selected by codevogel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants