Class: Escalator::Command::Confuse

Inherits:
Escalator::Command show all
Defined in:
lib/escalator/command/confuse.rb

Defined Under Namespace

Classes: Help

Constant Summary

Constants inherited from Escalator::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Confuse

Returns a new instance of Confuse.



53
54
55
56
57
58
59
# File 'lib/escalator/command/confuse.rb', line 53

def initialize argv
  @keywords = argv.arguments!.select { |arg| !arg.empty? }
  @project_path = argv.option "project-path", ""
  @output_path = argv.option "output-path", ""
  @show_output = argv.flag? "show-output", false
  super
end

Instance Attribute Details

#keywordsObject (readonly)

Returns the value of attribute keywords.



18
19
20
# File 'lib/escalator/command/confuse.rb', line 18

def keywords
  @keywords
end

#output_pathObject (readonly)

Returns the value of attribute output_path.



22
23
24
# File 'lib/escalator/command/confuse.rb', line 22

def output_path
  @output_path
end

#project_pathObject (readonly)

Returns the value of attribute project_path.



20
21
22
# File 'lib/escalator/command/confuse.rb', line 20

def project_path
  @project_path
end

#show_outputObject (readonly) Also known as: show_output?

Returns the value of attribute show_output.



24
25
26
# File 'lib/escalator/command/confuse.rb', line 24

def show_output
  @show_output
end

Class Method Details

.optionsObject



45
46
47
48
49
50
51
# File 'lib/escalator/command/confuse.rb', line 45

def self.options
  [
    ["--project-path=path", "path 为 .xcodeproj 源路径"],
    ["--output-path=path",  "path 为混淆工程存放路径"],
    ["--show-output",       "文件管理中展示输出文件夹, 默认: 否"]
  ].concat super
end

Instance Method Details

#help!(error_message = nil) ⇒ Object



74
75
76
# File 'lib/escalator/command/confuse.rb', line 74

def help!(error_message = nil)
  invoked_command_class.help!(error_message, Help)
end

#runObject



78
79
80
# File 'lib/escalator/command/confuse.rb', line 78

def run
  Escalator::Confuse.run self
end

#validate!Object



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/escalator/command/confuse.rb', line 61

def validate!
  super
  if keywords.empty?
    help! "未检测到 KEYWORD 参数"
  end
  if project_path.empty?
    help! "未检测到 --project-path 参数"
  end
  if output_path.empty?
    help! "未检测到 --output-path 参数"
  end
end