Class: Skylab::Face::Command::Namespace
Constant Summary
Skylab::Face::Colors::Esc, Skylab::Face::Colors::Styles
Constants included
from Treeish
Treeish::Indent
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
bold, hi, highlight_header, ohno, style, yelo
command_definitions, command_tree, inherited, method_added, namespace, on, option_definitions, option_parser
Methods included from Treeish
[], #ambiguous_command, #command_tree, #expecting, #find_command, #help, #option_parser, #run_opts, #unrecognized_command, #usage_string
Methods included from Nodeish
#build_empty_option_parser, #invite, #invocation_string, #parent=, #usage
Class Attribute Details
.namespace_name ⇒ Object
Returns the value of attribute namespace_name.
334
335
336
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 334
def namespace_name
@namespace_name
end
|
Instance Attribute Details
#err ⇒ Object
Returns the value of attribute err.
301
302
303
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 301
def err
@err
end
|
#out ⇒ Object
Returns the value of attribute out.
301
302
303
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 301
def out
@out
end
|
Class Method Details
.add_definition(arr) ⇒ Object
283
284
285
286
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 283
def add_definition arr
@definitions.push arr
arr
end
|
.build(name, &block) ⇒ Object
306
307
308
309
310
311
312
313
314
315
316
317
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 306
def self.build name, &block
name.kind_of?(Symbol) or return name
name = name.to_s
Class.new(self).class_eval do
self.namespace_name = name
x = class << self; self end
x.send(:define_method, :inspect) { "#<#{name}:Namespace>" }
x.send(:alias_method, :to_s, :inspect)
class_eval(&block)
self
end
end
|
.for_run(parent, name_as_used) ⇒ Object
320
321
322
323
324
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 320
def for_run parent, name_as_used
namespace_runner = new
namespace_runner.init_for_run parent, name_as_used
namespace_runner
end
|
.method_symbol ⇒ Object
325
326
327
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 325
def method_symbol
nil end
|
.name ⇒ Object
328
329
330
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 328
def name
@namespace_name
end
|
.namespaces ⇒ Object
287
288
289
290
291
292
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 287
def namespaces
@definitions.each_with_index do |defn, idx|
defn.kind_of?(Class) or @definitions[idx] = defn[0].build(*defn[1], &defn[2])
end
@definitions
end
|
.parent=(parent) ⇒ Object
335
336
337
338
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 335
def parent= parent
@parent and fail("won't overwrite parent")
@parent = parent
end
|
.summary ⇒ Object
339
340
341
342
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 339
def summary
a = command_tree.map { |c| hi(c.name) }
["child command#{'s' if a.length != 1}: {#{a * '|'}}"]
end
|
Instance Method Details
#init_for_run(parent, name_as_used) ⇒ Object
295
296
297
298
299
300
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 295
def init_for_run parent, name_as_used
@name_as_used = name_as_used
@parent = parent
@out = @parent.out
@err = @parent.err
end
|
#inspect ⇒ Object
305
306
307
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 305
def name
interface.namespace_name
end
|
#name ⇒ Object
302
303
304
|
# File 'lib/myterm/vendor/skylab/face/cli.rb', line 302
def name
interface.namespace_name
end
|