Class: RVC::CmdModule
- Inherits:
-
Object
show all
- Includes:
- Util
- Defined in:
- lib/rvc/modules.rb
Constant Summary
Constants included
from Util
Util::PROGRESS_BAR_LEFT, Util::PROGRESS_BAR_MIDDLE, Util::PROGRESS_BAR_RIGHT, Util::UserError
Instance Method Summary
collapse
Methods included from Util
#collect_children, #display_inventory, #err, #interactive?, #lookup, #lookup!, #lookup_single, #lookup_single!, #menu, #metric, #one_progress, #progress, #retrieve_fields, #search_path, #single_connection, #status_color, #system_fg, #tasks, #tcsetpgrp, #terminal_columns
Constructor Details
#initialize(module_name) ⇒ CmdModule
Returns a new instance of CmdModule.
32
33
34
35
36
37
|
# File 'lib/rvc/modules.rb', line 32
def initialize module_name
@module_name = module_name
@opts = {}
@completors = {}
super()
end
|
Instance Method Details
#commands ⇒ Object
39
40
41
|
# File 'lib/rvc/modules.rb', line 39
def commands
@opts.keys
end
|
#completor_for(cmd) ⇒ Object
73
74
75
|
# File 'lib/rvc/modules.rb', line 73
def completor_for cmd
@completors[cmd]
end
|
#has_command?(cmd) ⇒ Boolean
43
44
45
|
# File 'lib/rvc/modules.rb', line 43
def has_command? cmd
@opts.member? cmd
end
|
#opts(cmd, &b) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/rvc/modules.rb', line 47
def opts cmd, &b
if cmd.to_s =~ /[A-Z]/
fail "Camel-casing is not allowed (#{cmd.to_s})"
end
@opts[cmd] = OptionParser.new cmd.to_s, &b
@opts[cmd].specs.each do |name,spec|
if name.to_s =~ /[A-Z]/
fail "Camel-casing is not allowed (#{cmd.to_s} option #{name})"
end
end
end
|
#opts_for(cmd) ⇒ Object
65
66
67
|
# File 'lib/rvc/modules.rb', line 65
def opts_for cmd
@opts[cmd]
end
|
#raw_opts(cmd, summary) ⇒ Object
61
62
63
|
# File 'lib/rvc/modules.rb', line 61
def raw_opts cmd, summary
@opts[cmd] = RawOptionParser.new cmd.to_s, summary
end
|
#rvc_alias(cmd, target = nil) ⇒ Object
77
78
79
80
|
# File 'lib/rvc/modules.rb', line 77
def rvc_alias cmd, target=nil
target ||= cmd
RVC::ALIASES[target.to_s] = "#{@module_name}.#{cmd}"
end
|
#rvc_completor(cmd, &b) ⇒ Object
69
70
71
|
# File 'lib/rvc/modules.rb', line 69
def rvc_completor cmd, &b
@completors[cmd] = b
end
|