Skip to content

Navigation Menu

Sign in
Sign up

We need a way of flagging a default command #77

Unanswered
boblail asked this question in General
Discussion options

For example,

  • install is the default command of the Bundler CLI: bundle is short for bundle install
  • push is the default subcommand of git stash: git stash is short for git stash push

This could just be a boolean default on the Command object

Field Name Type Default Value Description
default bool false Indicates whether or not the subcommand will be assumed if it is omitted in command line

Shall we specify that default may be true for only one subcommand and not for the root command?

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

Yes, that sounds reasonable to be able to specify a default command.

The question is whether it's possible to specify it so it can only be done once.
Maybe on the document level? Could be an array of commands, such as defaultCommand: ["bundle", "install"]?

You must be logged in to vote
2 replies
Comment options

The question is whether it's possible to specify it so it can only be done once.

Yeah, I think so!

But maybe not on Document — since a multi-cli might have several default subcommands in various paths. For example,

  • git remote -> git remote show
  • git stash -> git stash save

What if Command (including the root command) has a field defaultCommand that's a string instead of an array?

You'd express the git example like this:

{
 "name": "git", // pseudo: depends on where we land with #70 
 "commands": [
 {
 "name": "remote",
 "defaultCommand": "show",
 "commands:": [
 {
 "name": "show",
 // ...
 }
 ]
 },
 {
 "name": "stash",
 "defaultCommand": "save",
 "commands:": [
 {
 "name": "save",
 // ...
 }
 ]
 },
 // ...
 ]
}
Comment options

@patriksvensson, is my answer acceptable to you? If so, I'd love to land this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /