Class: Erlnixify::Opts

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

Overview

The Opts class provides options parsing support for erlnixify. It is similar to settings with the exception that it is designed to get its values from the command line.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Opts

Returns a new instance of Opts.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/erlnixify/opts.rb', line 13

def initialize(args)
  cmd = :start
  @opts = Slop.parse(args) do

    banner = "Usage: erlnixify [options]"

    command 'startdeamon' do
      on :b, :release=, 'Release Root Directory'
      on :e, :erlang=, 'Erlang Root Directory'
      on :o, :home=, "The home directory to explicitly set"
      on :n, :name=, "The short name of the node to be managed"
      on :fullnode=, "The fully qualified node name"
      on :m, :command=, "The command to run to start the release"
      on :k, :check=, "The command to check if the release is active"
      on :r, :checkregex=, "The regex that must match to the output of check command"
      on :x, :cookiefile=, "A file that contains the erlang cookie, not needed if cookie is set"
      on :i, :cookie=, "The cookie itself, not needed if cookie-file is set"
      on(:t, :startuptimeout=,
         "The amount of time to let the system startup in seconds",
         as: Integer)
      on(:a, :checkinterval=,
         "How often erlnixify should check to see if the system is still running",
         as: Integer)
      on(:w, :checktimeout=,
         "The longest time a check can run, defaults to 30 seconds",
         as: Integer)
      on :c, :config=, "A file that contains the YAML based config for this system"
      on :v, :version, "Show the Version"

      run do |opts, args|
        cmd = :startdeamon
      end
    end

    command 'start' do
      on :b, :release=, 'Release Root Directory'
      on :e, :erlang=, 'Erlang Root Directory'
      on :o, :home=, "The home directory to explicitly set"
      on :n, :name=, "The short name of the node to be managed"
      on :fullnode=, "The fully qualified node name"
      on :m, :command=, "The command to run to start the release"
      on :k, :check=, "The command to check if the release is active"
      on :r, :checkregex=, "The regex that must match to the output of check command"
      on :x, :cookiefile=, "A file that contains the erlang cookie, not needed if cookie is set"
      on :i, :cookie=, "The cookie itself, not needed if cookie-file is set"
      on(:t, :startuptimeout=,
         "The amount of time to let the system startup in seconds",
         as: Integer)
      on(:a, :checkinterval=,
         "How often erlnixify should check to see if the system is still running",
         as: Integer)
      on(:w, :checktimeout=,
         "The longest time a check can run, defaults to 30 seconds",
         as: Integer)
      on :c, :config=, "A file that contains the YAML based config for this system"
      on :v, :version, "Show the Version"

      run do |opts, args|
        cmd = :start
      end
    end

    command 'stop' do
      on :b, :release=, 'Release Root Directory'
      on :e, :erlang=, 'Erlang Root Directory'
      on :o, :home=, "The home directory to explicitly set"
      on :n, :name=, "The short name of the node to be managed"
      on :fullnode=, "The fully qualified node name"
      on :k, :check=, "The command to check if the release is active"
      on :r, :checkregex=, "The regex that must match to the output of check command"
      on :x, :cookiefile=, "A file that contains the erlang cookie, not needed if cookie is set"
      on :i, :cookie=, "The cookie itself, not needed if cookie-file is set"
      on(:t, :startuptimeout=,
         "The amount of time to let the system startup in seconds",
         as: Integer)
      on(:a, :checkinterval=,
         "How often erlnixify should check to see if the system is still running",
         as: Integer)
      on(:w, :checktimeout=,
         "The longest time a check can run, defaults to 30 seconds",
         as: Integer)
      on :c, :config=, "A file that contains the YAML based config for this system"
      on :v, :version, "Show the Version"

      run do |opts, args|
        cmd = :stop
      end
    end

    command 'status' do
      on :b, :release=, 'Release Root Directory'
      on :e, :erlang=, 'Erlang Root Directory'
      on :o, :home=, "The home directory to explicitly set"
      on :n, :name=, "The short name of the node to be managed"
      on :fullnode=, "The fully qualified node name"
      on :k, :check=, "The command to check if the release is active"
      on :r, :checkregex=, "The regex that must match to the output of check command"
      on :x, :cookiefile=, "A file that contains the erlang cookie, not needed if cookie is set"
      on :i, :cookie=, "The cookie itself, not needed if cookie-file is set"
      on(:t, :startuptimeout=,
         "The amount of time to let the system startup in seconds",
         as: Integer)
      on(:a, :checkinterval=,
         "How often erlnixify should check to see if the system is still running",
         as: Integer)
      on(:w, :checktimeout=,
         "The longest time a check can run, defaults to 30 seconds",
         as: Integer)
      on :c, :config=, "A file that contains the YAML based config for this system"
      on :v, :version, "Show the Version"

      run do |opts, args|
        cmd = :status
      end
    end

  end

  @options = opts.to_hash(true)
  @command = cmd
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



11
12
13
# File 'lib/erlnixify/opts.rb', line 11

def command
  @command
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/erlnixify/opts.rb', line 11

def options
  @options
end

#optsObject (readonly)

Returns the value of attribute opts.



11
12
13
# File 'lib/erlnixify/opts.rb', line 11

def opts
  @opts
end