Class: Ops

Inherits:
Object
  • Object
show all
Defined in:
lib/ops.rb

Overview

executes commands based on local ‘ops.yml`

Defined Under Namespace

Classes: UnknownActionError

Constant Summary collapse

CONFIG_FILE =
"ops.yml"
INVALID_SYNTAX_EXIT_CODE =
1

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Ops

Returns a new instance of Ops.



21
22
23
24
25
26
# File 'lib/ops.rb', line 21

def initialize(argv)
  @action_name = argv[0]
  @args = argv[1..-1]

  Options.set(config["options"] || {})
end

Instance Method Details

#runObject



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ops.rb', line 28

def run
  exit(INVALID_SYNTAX_EXIT_CODE) unless syntax_valid?

  environment.set_variables

  return builtin.run if builtin

  Output.warn("Running '#{action}' from #{CONFIG_FILE}...")
  action.run
rescue UnknownActionError => e
  Output.error("Error: #{e}")
end