Class: Mistilteinn::Cli::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/mistilteinn/cli/command.rb

Direct Known Subclasses

Create, Edit, Init, IsInside, List, SelfCheck

Constant Summary collapse

@@klass =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Command

Returns a new instance of Command.



8
9
10
11
12
# File 'lib/mistilteinn/cli/command.rb', line 8

def initialize(obj)
  obj.command name do|opts|
    opts.description = desc
  end
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



6
7
8
# File 'lib/mistilteinn/cli/command.rb', line 6

def args
  @args
end

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/mistilteinn/cli/command.rb', line 6

def config
  @config
end

#itsObject (readonly)

Returns the value of attribute its.



6
7
8
# File 'lib/mistilteinn/cli/command.rb', line 6

def its
  @its
end

Class Method Details

.commandsObject



31
32
33
# File 'lib/mistilteinn/cli/command.rb', line 31

def commands
  @@klass
end

.desc(x) ⇒ Object



39
40
41
# File 'lib/mistilteinn/cli/command.rb', line 39

def desc(x)
  define_method(:desc){ x }
end

.inherited(k) ⇒ Object



27
28
29
# File 'lib/mistilteinn/cli/command.rb', line 27

def inherited(k)
  @@klass << k
end

.name(x) ⇒ Object



35
36
37
# File 'lib/mistilteinn/cli/command.rb', line 35

def name(x)
  define_method(:name){ x.to_sym }
end

Instance Method Details

#run(config, args) ⇒ Object



19
20
21
22
23
# File 'lib/mistilteinn/cli/command.rb', line 19

def run(config, args)
  @config = config
  @args   = args
  action
end