Sha256: 4b86edb2cbd2c1fd0f406e773c36ed440c39d78ac012802bfd9e0ec642f16be5

Contents?: true

Size: 988 Bytes

Versions: 2

Compression:

Stored size: 988 Bytes

Contents

module <%= project_class_name %>
  class CLI < Command
    class_option :verbose, type: :boolean
    class_option :noop, type: :boolean

    desc "hello NAME", "Say hello to NAME."
    long_desc Help.text(:hello)
    option :from, desc: "from person"
    def hello(name="you")
      puts "from: #{options[:from]}" if options[:from]
      puts "Hello #{name}"
    end
<% if options[:subcommand] -%>
    desc "sub SUBCOMMAND", "sub subcommands"
    long_desc Help.text(:sub)
    subcommand "sub", Sub
<% end -%>

    desc "completion *PARAMS", "Prints words for auto-completion."
    long_desc Help.text("completion")
    def completion(*params)
      Completer.new(CLI, *params).run
    end

    desc "completion_script", "Generates a script that can be eval to setup auto-completion."
    long_desc Help.text("completion_script")
    def completion_script
      Completer::Script.generate
    end

    desc "version", "prints version"
    def version
      puts VERSION
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cli-template-4.0.1 lib/templates/default/lib/%underscored_name%/cli.rb.tt
cli-template-4.0.0 lib/templates/default/lib/%underscored_name%/cli.rb.tt