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.

Adding CommandOptions to branch requires options to be defined BEFORE subcommands

See original GitHub issue

Information

  • OS: Windows
  • Version: Commit: e4dda28
  • Windows terminal

Describe the bug Adding CommandOptions to branch requires options to be defined BEFORE subcommands

To Reproduce Use Demo project and extend AddSettings with this:

        [CommandOption("--quiet")]
        [Description("Quite mode")]
        public bool Quiet { get; set; }
> Demo.exe add wo package pkt --quiet
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Name             β”‚ Value β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ PackageName      β”‚ pkt   β”‚
β”‚ Version          β”‚ null  β”‚
β”‚ Framework        β”‚ null  β”‚
β”‚ NoRestore        β”‚ False β”‚
β”‚ Source           β”‚ null  β”‚
β”‚ PackageDirectory β”‚ null  β”‚
β”‚ Interactive      β”‚ False β”‚
β”‚ Project          β”‚ wo    β”‚
β”‚ Quiet            β”‚ False β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜

Quit is here FALSE even though I clearly gave it as an option to the command.

Demo.exe add wo --quiet package pkt
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Name             β”‚ Value β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€
β”‚ PackageName      β”‚ pkt   β”‚
β”‚ Version          β”‚ null  β”‚
β”‚ Framework        β”‚ null  β”‚
β”‚ NoRestore        β”‚ False β”‚
β”‚ Source           β”‚ null  β”‚
β”‚ PackageDirectory β”‚ null  β”‚
β”‚ Interactive      β”‚ False β”‚
β”‚ Project          β”‚ wo    β”‚
β”‚ Quiet            β”‚ True  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”˜

Gives Quite = true

Expected behavior I expected CommandOption:s can be assigned anywhere on the commandline. IΒ΄ve never seen CLI:s requiring this strict order.

With CommandArguments it’s might be more intuitive to assign arguments to each command in order: β€œX arg1 arg2 Y arg1 arg2”. But this cant be the case with options. Examples of usages would be great on the https://spectreconsole.net/cli/composing page

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
patriksvenssoncommented, May 3, 2021

@Goffen Thanks for reporting this. Will take a look at it closer when I have some spare time.

0reactions
Simonl9lcommented, Jan 31, 2022

@PsychoNineSix Id suggest that it is also valuable to want to place the settings on the branch, and expect the Argument to show as you had originally expected (per --help options) as the argument applies to all subcommands - so I’d say un-scratch!

I assume it is β€œnot normal” to have branch options separated from their sub command options as today all the options are moved to the end regardless of what part of the setting call hierarchy they are in - this implies that there are multiple sets of options, those as part of the branch and this and part of the selected sub command one is looking at --help for?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why design global options need to be before subcommands?
Global options need to appear before subcommands, not anywhere, why are they designed this way? This is not the same as spf13/cobra.
Read more >
Advanced command creation
This allows you to branch a single command to require different options depending on the subcommand chosen.
Read more >
Git - git-branch Documentation
Defines, together with branch.<name>.remote, the upstream branch for the given branch. It tells git fetch/git pull/git rebase which branch to merge and can...
Read more >
Reference manual for CVS commands
Go to the previous, next section. Reference manual for CVS commands. This appendix describes how to invoke CVS, and describes in detail those...
Read more >
Quick Guide
The easiest way is to add a @Command -annotated method to the command class. For each option and positional parameter of the subcommand,...
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