Skip to content

Main command without actions #15

@BigBoyBarney

Description

@BigBoyBarney

Hi! Thanks for this shard!

I'd like to have the app print the help message if it's run without arguments and have all actions done through subcommands.

Example:

class Main < Cling::Command
  def setup : Nil
    @name = "main"
    @description = "main description"
  end

  def run(arguments : Cling::Arguments, options : Cling::Options) : Nil
    puts help_template
  end
end

class SubcommandOne < Cling::Command
  def setup : Nil
    @name = "subcommand-one"
    @description = "Subcommand one"
  end

  def run(arguments : Cling::Arguments, options : Cling::Options) : Nil
    # stuff to do
  end
end

main = Main.new
main.add_command(SubcommandOne.new)
main.execute(ARGV)

This works, but the help message looks like this

Usage:
	main

Commands:
	subcommand-one

Would it be possible to print a placeholder for the commands like this?

Usage:
	main <command>

Commands:
	subcommand-one

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions