Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Args for default subcommand in a supercommand #12

@Jens0512

Description

@Jens0512

With a structure like this:

include Cli

class To < SuperCommand
    command "go-to", default: true

    class GoTo < Command
        def run
          # ... 
        end
        class Options
            arg "where", required: true
        end   
    end

    class OtherCommand < Command
        def run
          # ... 
        end
    end

    class Help
        header "Goes to specified location"
    end

    class Options
        help
    end
end

Now if i were to run to home– instead of running "go-to" with the argument "home" as "where"; it throws the help screen screen at me. Running to alone says i need to specify the where argument.
What about making it so if a default command is set and has (required?) arguments, it checks wether whatever is passed after supercommand invoke is a subcommand or not? If it is not, pass it as an argument to the default command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions