Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Options in variadic arguments

See original GitHub issue

In my particular use case I’d need to accept a variable number of cli arguments (including options) unrelated to cliffy after a series of valid args, for example:

mycmd --myoption mysubcmd myarg other args and --options
                 cliffy args <-|-> other args

To do this I’ve been using a variadic argument in mysubcmd

new Command()
  .command('mysubcmd [myarg] [otherArgs...]');

but I didn’t take into account that --options could break it

[ERROR:...] Unknown option --options

Do you have any suggestions on how to accomplish this?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

c4sparcommented, Jun 4, 2020

Hey @umbopepato,

in v0.9.0 is now a new way to resolve your issue. You can use .stopEarly() instead of .useRawArgs(). If stopEarly is enabled, all arguments, starting from the first non option argument, will be interpreted as raw argument. In contrast to .useRawArgs() the --help and --version option will still work.

umbopepatocommented, Jun 5, 2020

Awesome! Thank you @c4spar

Read more comments on GitHub >

github_iconTop Results From Across the Web

Variadic arguments -
When a variadic function is called, after lvalue-to-rvalue, array-to-pointer, and function-to-pointer conversions, each argument that is a part of the variable ...
Read more >
Ultimate Guide to Go Variadic Functions | by Inanc Gumus
Accepting variable types of arguments. For example, Go Stdlib's Printf variadic func accepts any type of input params by using an empty interface...
Read more >
Variadic function - Wikipedia
In mathematics and in computer programming, a variadic function is a function of indefinite arity, i.e., one which accepts a variable number of...
Read more >
How To Use Variadic Functions in Go - DigitalOcean
A variadic function is a function that accepts zero, one, or more values as a single argument. While variadic functions are not the...
Read more >
Modern C++ and Variadic Functions: How to Shoot Yourself in ...
It is possible to declare function with a variable number of arguments, i.e. the number of function arguments can be greater than the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found