Class: Gitnesse::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/gitnesse/cli.rb,
lib/gitnesse/cli/task.rb,
lib/gitnesse/cli/helpers/wiki_helpers.rb,
lib/gitnesse/cli/helpers/config_helpers.rb,
lib/gitnesse/cli/helpers/feature_helpers.rb

Defined Under Namespace

Modules: ConfigHelpers, FeatureHelpers, WikiHelpers Classes: Task

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out = STDOUT) ⇒ Cli

Returns a new instance of Cli.



12
13
14
15
# File 'lib/gitnesse/cli.rb', line 12

def initialize(out = STDOUT)
  @out = out
  setup_parser
end

Instance Attribute Details

#outObject

Returns the value of attribute out.



10
11
12
# File 'lib/gitnesse/cli.rb', line 10

def out
  @out
end

#parserObject

Returns the value of attribute parser.



10
11
12
# File 'lib/gitnesse/cli.rb', line 10

def parser
  @parser
end

Class Method Details

.task(*names, &block) ⇒ Object



53
54
55
56
57
58
# File 'lib/gitnesse/cli/task.rb', line 53

def task(*names, &block)
  task = Class.new(Task, &block)
  names.map!(&:to_s)
  task.name = names.first
  names.each { |name| tasks[name] = task }
end

.tasksObject



60
61
62
# File 'lib/gitnesse/cli/task.rb', line 60

def tasks
  @tasks ||= {}
end

Instance Method Details

#parse(args = ARGV) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitnesse/cli.rb', line 17

def parse(args = ARGV)
  # gitnesse run will pass all arguments onto cucumber
  parser.parse! args unless ARGV.first == "run"

  arg = args.shift.to_s

  if task = tasks[arg]
    task.perform(*args)
  else
    abort "No such task."
  end
end

#tasksObject



48
49
50
# File 'lib/gitnesse/cli/task.rb', line 48

def tasks
  @tasks ||= Hash[self.class.tasks.map { |name, t| [name, t.new(out)] }]
end