Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parent flags/arguments in subcommands help #24

Open
EppO opened this issue Jun 12, 2020 · 2 comments
Open

Parent flags/arguments in subcommands help #24

EppO opened this issue Jun 12, 2020 · 2 comments

Comments

@EppO
Copy link

EppO commented Jun 12, 2020

Hi,

currently, the help of the subcommands doesn't show the global flags/arguments of the parent.
Taking the following example:

equire "admiral"

class ParentCmd < Admiral::Command
  class ChildCmd < Admiral::Command
    define_help description: "Execute a subcommand."

    define_argument childarg : String, description: "Arg for child", required: true

    def run
      puts "in ChildCmd with #{arguments.childarg}"
    end
  end

  register_sub_command child : ChildCmd, "Child Command"

  define_flag parentflag : Bool, description: "Parent flag", default: false, short: p
  define_help description: "Test subcommands help with global flag"

  def run
    puts help
  end
end

ParentCmd.run

I would expect the parentflag to show up in the ChildCmd help page:

$ ./testsub --help
Usage:
  ./testsub [flags...] [arg...]

Test subcommands help with global flag

Flags:
  --help            # Displays help for the current command.
  --parentflag, -p  # Parent flag

Subcommands:
  child             # Execute a subcommand.

$ /testsub child --help 
Usage:
  ./testsub child [flags...] <childarg> [arg...]

Execute a subcommand.

Flags:
  --help               # Displays help for the current command.

Arguments:
  childarg (required)  # Arg for child
@jwaldrip
Copy link
Owner

jwaldrip commented Jul 2, 2020

I will look into this.

@mjblack
Copy link

mjblack commented Jun 6, 2024

has there been any effort towards implementing this feature?

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

No branches or pull requests

3 participants