Class: Ripe::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/ripe/cli.rb,
lib/ripe/cli/helper.rb

Overview

This class represents the CLI interface to ripe. The methods defined in this class are wrappers for the methods defined in Ripe::Repo and Ripe::WorkerController.

Defined Under Namespace

Classes: Helper

Instance Method Summary collapse

Instance Method Details

#consoleObject

Launch ripe console. It is a REPL bound to the context of a Ripe::WorkerController initialized in the working directory.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ripe/cli.rb', line 46

def console
  repo = Repo.new
  repo.attach

  unless repo.has_repository?
    abort "Cannot launch console: ripe repo not initialized"
  end

  # Do not send arguments to the REPL
  ARGV.clear

  Ripl.config[:prompt] = proc do
    # This is the only place I could think of placing +Hirb#enable+.
    Hirb.enable unless Hirb::View.enabled?
    'ripe> '
  end

  # Launch the REPL session in the context of +WorkerController+.
  Ripl.start :binding => repo.controller.instance_eval { binding }
end

#initObject

Initialize ripe repository.



30
31
32
33
34
# File 'lib/ripe/cli.rb', line 30

def init
  puts "Initialized ripe repository in #{Dir.pwd}"
  repo = Repo.new
  repo.attach_or_create
end

#prepare(*samples) ⇒ Object

Prepare samples.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/ripe/cli.rb', line 87

def prepare(*samples)
  repo = Repo.new
  repo.attach

  unless repo.has_repository?
    abort 'Cannot prepare samples: ripe repo not initialized'
  end

  abort 'No samples specified.' if samples.length == 0

  config = options[:config] ? Helper.parse_config(options[:config]) : {}
  workflow_options = config[options[:workflow].to_sym] ||= {}
  workflow_options.merge!(Helper.parse_cli_opts(options[:options]))

  workers = repo.controller.prepare(options[:workflow], samples, workflow_options)

  repo.controller.start(workers) if options[:start]
end

#versionObject

Retrieve ripe version.



113
# File 'lib/ripe/cli.rb', line 113

desc 'version', 'Retrieve ripe version'