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.

Feature Request: Ability to specify arguments before subcommands

See original GitHub issue

Is your feature request related to a problem? Please describe. I’d like to create a commandline that allows me to do this:

program.exe -d value alpha // -d is currently ignored
program.exe -d value beta // -d is currently ignored
program.exe alpha -d value
program.exe beta -d value

That is… the ability to specify some argument before a subcommand, to specify some common argument. My subcommands are currently of an inherited form, where the base class has arguments such as “Database path”, and I’d like that to take affect no matter where it was placed.

The odd thing is, even if I specify the “-d” before my subcommand, no exception is thrown - but the argument is discarded. I noticed because my database hadn’t been modified … in the place I expected.

Describe the solution you’d like Either a parsing exception should be thrown, or the value should be used. In no case should the value be silently ignored.

Describe alternatives you’ve considered My workaround is to remember to put the subcommand first, always.

I vaguely recall other tools have the opposite issue - they will ignore common arguments that go after some “action”. The dotnet CLI seems to also exhibit this, although they’ll warn you about it.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
vpkopylovcommented, Aug 30, 2019

This is already fixed in master at #239 and originally reported s #236

As the cyclic dependency is a manifestation of improper use. And fixing the cause makes the issue go away. I think its ok to wait until v2.4.0 to get the proper error message.

I confirm that SubcommandCycleException is thrown when running this code on master

1reaction
JakeStaTeresacommented, Aug 30, 2019

This is already fixed in master at #239 and originally reported s #236

As the cyclic dependency is a manifestation of improper use. And fixing the cause makes the issue go away. I think its ok to wait until v2.4.0 to get the proper error message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add common options to sub commands which can ...
Yes you can add common options to sub commands which can go after the name of the sub command. You can have options...
Read more >
ArgumentParser subcommand autodiscovery!
Hi everyone, currently over on the ArgumentParser repo, we have a PR to implement "subcommand autodiscovery"! With this feature, you no ...
Read more >
clap - crates.io: Rust Package Registry
It is a simple-to-use, efficient, and full-featured library for parsing command line arguments and subcommands when writing console/terminal ...
Read more >
Build Command-Line Interfaces With Python's argparse
This module allows you to define the arguments and options that your app will require. Then argparse will take care of parsing those...
Read more >
argparse
84, New, positional arguments before options cause all options to be in REMAINDER ... 71, Duplicate, Feature Request: Ability to remove argument groups ......
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