Class: Devkitkat::Command
- Inherits:
-
Object
- Object
- Devkitkat::Command
- Defined in:
- lib/devkitkat/command.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#script ⇒ Object
readonly
Returns the value of attribute script.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #create_tmp_dir ⇒ Object
-
#initialize ⇒ Command
constructor
A new instance of Command.
- #kit_root ⇒ Object
- #tmp_dir ⇒ Object
- #tty? ⇒ Boolean
- #variables ⇒ Object
Constructor Details
#initialize ⇒ Command
Returns a new instance of Command.
5 6 7 8 9 10 11 12 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 |
# File 'lib/devkitkat/command.rb', line 5 def initialize @options = {} OptionParser.new do |opts| opts. = "Usage: devkitkat <script> <target> [options]" opts.on("-p", "--path PATH", "The root path of the .devkitkat.yml") do |v| [:root_path] = v end opts.on("-e", "--exclude SERVICE", "Exclude serviced from the specified target") do |v| [:exclude] ||= [] [:exclude] << v end opts.on("-e", "--env-var VARIABLE", "additional environment variables") do |v| [:variables] ||= {} [:variables].merge!(Hash[*v.split('=')]) end opts.on("-d", "--depth DEPTH", "Git depth for pull/fetch") do |v| [:git_depth] = v end opts.on("-r", "--remote REMOTE", "Git remote") do |v| [:git_remote] = v end opts.on("-b", "--branch BRANCH", "Git branch") do |v| [:git_branch] = v end opts.on("-t", "--tty", "TTY mode. In this mode, log won't be emitted.") do |v| [:tty] = v end end.parse! @script, @target, *@args = ARGV end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
3 4 5 |
# File 'lib/devkitkat/command.rb', line 3 def args @args end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/devkitkat/command.rb', line 3 def @options end |
#script ⇒ Object (readonly)
Returns the value of attribute script.
3 4 5 |
# File 'lib/devkitkat/command.rb', line 3 def script @script end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
3 4 5 |
# File 'lib/devkitkat/command.rb', line 3 def target @target end |
Instance Method Details
#create_tmp_dir ⇒ Object
57 58 59 |
# File 'lib/devkitkat/command.rb', line 57 def create_tmp_dir FileUtils.mkdir_p(tmp_dir) end |
#kit_root ⇒ Object
61 62 63 |
# File 'lib/devkitkat/command.rb', line 61 def kit_root Dir.pwd # TODO: root_path end |
#tmp_dir ⇒ Object
53 54 55 |
# File 'lib/devkitkat/command.rb', line 53 def tmp_dir File.join(kit_root, 'tmp') end |
#tty? ⇒ Boolean
45 46 47 |
# File 'lib/devkitkat/command.rb', line 45 def tty? [:tty] end |
#variables ⇒ Object
49 50 51 |
# File 'lib/devkitkat/command.rb', line 49 def variables [:variables] end |