Class: MisterBin::Command

Inherits:
Object
  • Object
show all
Includes:
Colsole
Defined in:
lib/mister_bin/command.rb

Class Method Summary collapse

Class Method Details

.descriptionObject



9
10
11
# File 'lib/mister_bin/command.rb', line 9

def description
  maker.summary || maker.help || ''
end

.environment(name, value) ⇒ Object



53
54
55
# File 'lib/mister_bin/command.rb', line 53

def environment(name, value)
  maker.env_vars << [name, value]
end

.example(text) ⇒ Object



49
50
51
# File 'lib/mister_bin/command.rb', line 49

def example(text)
  maker.examples << text
end

.execute(argv = []) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/mister_bin/command.rb', line 13

def execute(argv=[])
  args = Docopt.docopt docopt, version: maker.version, argv: argv
  exitcode = new.run args
  exitcode.is_a?(Numeric) ? exitcode : 0

rescue Docopt::Exit => e
  puts e.message
  1
end

.help(text) ⇒ Object



29
30
31
# File 'lib/mister_bin/command.rb', line 29

def help(text)
  maker.help = text
end

.option(flags, text) ⇒ Object



41
42
43
# File 'lib/mister_bin/command.rb', line 41

def option(flags, text)
  maker.options << [flags, text]
end

.param(param, text) ⇒ Object



45
46
47
# File 'lib/mister_bin/command.rb', line 45

def param(param, text)
  maker.params << [param, text]
end

.summary(text) ⇒ Object

DSL



25
26
27
# File 'lib/mister_bin/command.rb', line 25

def summary(text)
  maker.summary = text
end

.usage(text) ⇒ Object



37
38
39
# File 'lib/mister_bin/command.rb', line 37

def usage(text)
  maker.usages << text
end

.version(text) ⇒ Object



33
34
35
# File 'lib/mister_bin/command.rb', line 33

def version(text)
  maker.version = text
end