Class: AqaraLocalizable::Command::Gen

Inherits:
AqaraLocalizable::Command show all
Defined in:
lib/Aqara_localizable/command/command_gen.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Gen

Returns a new instance of Gen.



7
8
9
10
11
12
# File 'lib/Aqara_localizable/command/command_gen.rb', line 7

def initialize(argv)
  super
  project_directory = argv.option('project-directory')
  project_directory = Dir.pwd if project_directory.nil?
  @project_directory = Pathname.new(project_directory).expand_path
end

Class Method Details

.optionsObject



21
22
23
24
25
# File 'lib/Aqara_localizable/command/command_gen.rb', line 21

def self.options
  [
    ['--project-directory=/project/dir/', 'The path to the root of the project directory']
  ].concat(super)
end

Instance Method Details

#runObject



27
28
29
30
31
32
33
34
# File 'lib/Aqara_localizable/command/command_gen.rb', line 27

def run
  puts '如果多语言脚本插件有问题可以找zxf看看'.green
  target_path = Pathname.new(File.dirname(__FILE__)).realpath.parent.parent
  puts target_path
  # system "pip3 install requests;pip3 install openpyxl"
  system "cd #{target_path}/script/ios_py_code;python3 ios_sp_str_generator.py #{@project_directory}"
  # system 'cd /lib/script/ios_py_code;python3 ios_sp_str_generator.py'
end

#validate!Object



14
15
16
17
18
19
# File 'lib/Aqara_localizable/command/command_gen.rb', line 14

def validate!
  super
  if @project_directory.nil?
    help! 'error: no input project directory which to use with the `--project-directory` option.'
  end
end