cli icon indicating copy to clipboard operation
cli copied to clipboard

Args for default subcommand in a supercommand

Open Jens0512 opened this issue 8 years ago • 0 comments

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.

Jens0512 avatar Dec 25 '17 11:12 Jens0512