Module: DuckTest::Usage

Included in:
Commands
Defined in:
lib/duck_test/usage.rb

Overview

Provides usage details for all of the console commands.

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) usage(key, show = false)

Note:

future version will pull usage info using i18n

Returns the value of show

Parameters:

  • key (Symbol)

    The usage details to display.

  • show (Boolean) (defaults to: false)

    Flag indicating if the details should be displayed. This value is often used by the calling code as part of an unless statement.

Returns:

  • (Boolean)

    Returns the value of show



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/duck_test/usage.rb', line 12

def usage(key, show = false)

  if show
    content = YAML.load_file(File.expand_path(__FILE__).gsub(".rb", ".yml"))
    case key
    when :usage
      puts "DuckTest #{VERSION}"
      puts content[:usage]

    else
      if content[key]
        puts content[key]
      else
        puts "help not found for command: #{key}"
      end
    end
  end

  return show
end