Class: Devkitkat::Command

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommand

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.banner = "Usage: devkitkat <script> <target> [options]"

    opts.on("-p", "--path PATH", "The root path of the .devkitkat.yml") do |v|
      options[:root_path] = v
    end

    opts.on("-e", "--exclude SERVICE", "Exclude serviced from the specified target") do |v|
      options[:exclude] ||= []
      options[:exclude] << v
    end

    opts.on("-e", "--env-var VARIABLE", "additional environment variables") do |v|
      options[:variables] ||= {}
      options[:variables].merge!(Hash[*v.split('=')])
    end

    opts.on("-d", "--depth DEPTH", "Git depth for pull/fetch") do |v|
      options[:git_depth] = v
    end

    opts.on("-r", "--remote REMOTE", "Git remote") do |v|
      options[:git_remote] = v
    end

    opts.on("-b", "--branch BRANCH", "Git branch") do |v|
      options[:git_branch] = v
    end

    opts.on("-t", "--tty", "TTY mode. In this mode, log won't be emitted.") do |v|
      options[:tty] = v
    end
  end.parse!

  @script, @target, *@args = ARGV
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



3
4
5
# File 'lib/devkitkat/command.rb', line 3

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/devkitkat/command.rb', line 3

def options
  @options
end

#scriptObject (readonly)

Returns the value of attribute script.



3
4
5
# File 'lib/devkitkat/command.rb', line 3

def script
  @script
end

#targetObject (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_dirObject



57
58
59
# File 'lib/devkitkat/command.rb', line 57

def create_tmp_dir
  FileUtils.mkdir_p(tmp_dir)
end

#kit_rootObject



61
62
63
# File 'lib/devkitkat/command.rb', line 61

def kit_root
  Dir.pwd # TODO: root_path
end

#tmp_dirObject



53
54
55
# File 'lib/devkitkat/command.rb', line 53

def tmp_dir
  File.join(kit_root, 'tmp')
end

#tty?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/devkitkat/command.rb', line 45

def tty?
  options[:tty]
end

#variablesObject



49
50
51
# File 'lib/devkitkat/command.rb', line 49

def variables
  options[:variables]
end