Module: Mwc::Utils::Command::ClassMethods

Defined in:
lib/mwc/utils/command.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#add_option(name, options = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add command options

Parameters:

  • name (String|Symbol)

    the option name

  • options (Hash) (defaults to: {})

    the option options

Since:

  • 0.1.0



103
104
105
106
# File 'lib/mwc/utils/command.rb', line 103

def add_option(name, options = {})
  @options ||= []
  @options.push([name, options])
end

#description(desc = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get or set command description

Parameters:

  • desc (String) (defaults to: nil)

    the command description

Since:

  • 0.1.0



46
47
48
49
50
# File 'lib/mwc/utils/command.rb', line 46

def description(desc = nil)
  return @description || name if desc.nil?

  @description = desc
end

#display?TrueClass, FalseClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The command should display or not

Returns:

  • (TrueClass, FalseClass)

    display on command

Since:

  • 0.1.0



58
59
60
61
62
# File 'lib/mwc/utils/command.rb', line 58

def display?
  return true if @display.nil?

  @display.call
end

#display_on(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Define the command display policy

Parameters:

  • proc (Proc)

    the display policy block

Since:

  • 0.1.0



70
71
72
73
74
# File 'lib/mwc/utils/command.rb', line 70

def display_on(&block)
  return unless block_given?

  @display = block
end

#name(name = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get or set command name

Parameters:

  • name (String) (defaults to: nil)

    the command name

Since:

  • 0.1.0



22
23
24
25
26
# File 'lib/mwc/utils/command.rb', line 22

def name(name = nil)
  return @name || self.name.split('::').last.downcase if name.nil?

  @name = name
end

#optionsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The command options

Since:

  • 0.1.0



92
93
94
# File 'lib/mwc/utils/command.rb', line 92

def options
  @options ||= []
end

#source_rootString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The thor template source root

Returns:

  • (String)

    the source root path

See Also:

Since:

  • 0.1.0



84
85
86
# File 'lib/mwc/utils/command.rb', line 84

def source_root
  Mwc.source_root
end

#usage(usage = nil) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set command usage

Parameters:

  • name (String)

    the command usage

Since:

  • 0.1.0



34
35
36
37
38
# File 'lib/mwc/utils/command.rb', line 34

def usage(usage = nil)
  return @usage || name if usage.nil?

  @usage = usage
end