question-mark
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.

Specifying that an Option requires another Option

See original GitHub issue

Issue by st1led Tuesday Apr 09, 2013 at 09:55 GMT _Originally opened as https://github.com/gsscoder/commandline/issues/76_


Hi everybody, is there a way in CommandLine (I guess in a way similar to what is done with mutually exclusive properties) to specify that an option requires another option to be set? This is a short example:

        [Option('v', "verbose",
            Required = false,
            DefaultValue = false,
            HelpText = "Prints log messages.")]
        public bool Verbose { get; set; }

        [Option('o', "optional-operation",
            Required = false,
            DefaultValue = false,
            HelpText = "Performs an operation (a.k.a. \"does something\") in the code.")]
        public bool PerformOperation { get; set; }

        [Option('t', "time-limit",
            Required = false,
            DefaultValue = false,
            HelpText = "Requires option -o. Specifies a time limit for the optional operation")]
        public int OperationTimeLimit { get; set; }

In this scenario, one would want to allow command line arguments like -o and -vot but not -vt or -t for instance, since in the latter the option -t is specified without -o. Is this currently possible in CommandLine?

Regards, Stefano

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
IanKempcommented, Feb 14, 2023

So… how do we do this? I can’t see anything in the wiki that indicates that this feature is available.

0reactions
rmeshksarcommented, Jul 18, 2023

Why is this issue closed? Is there anyway to do it now that is not documented?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Click Command Line Interfaces: Make options required if ...
This can be done by building a custom class derived from click.Option , and in that class over riding the click.Option.handle_parse_result() ...
Read more >
Options — Click Documentation (8.1.x)
The most basic option is a value option. These options accept one argument which is a value. If no type is provided, the...
Read more >
optparse — Parser for command line options
Each Option instance represents a set of synonymous command-line option strings, e.g. -f and --file . You can specify any number of short...
Read more >
How to define commands in System.CommandLine
Learn how to define commands, options, and arguments by using the System.Commandline library.
Read more >
Basic Options - Clikt
Options are added to commands by defining a property delegate with the option function. Basic Options¶. The default option takes one value of...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found