module CommandKit::Examples

Allows defining example commands for the command class.

## Examples

include CommandKit::Examples

examples [
  "my_cmd -o output.txt  path/to/file"
]

Public Instance Methods

examples() click to toggle source

@see ClassMethods#examples

@api semipublic

# File lib/command_kit/examples.rb, line 81
def examples
  self.class.examples
end
help() click to toggle source

Calls the superclass'es `#help` method, if it's defined, then calls {#help_examples}.

@api public

Calls superclass method CommandKit::Help#help
# File lib/command_kit/examples.rb, line 106
def help
  super

  help_examples
end
help_examples() click to toggle source

Prints the command class'es example commands.

@api semipublic

# File lib/command_kit/examples.rb, line 90
def help_examples
  if (examples = self.examples)
    puts
    puts "Examples:"
    examples.each do |command|
      puts "    #{command_name} #{command}"
    end
  end
end