Class: Flow::Cli::CmdManager

Inherits:
Thor
  • Object
show all
Defined in:
lib/flow/cli/cmd_manager.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ CmdManager

Returns a new instance of CmdManager.



11
12
13
14
15
# File 'lib/flow/cli/cmd_manager.rb', line 11

def initialize(*args)
  super(*args)
  @db_manager = Utils::DbManager
  @cmd_helper = Utils::CmdHelper.instance
end

Instance Method Details

#build_yaml_fileObject

Raises:



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/flow/cli/cmd_manager.rb', line 21

def build_yaml_file
  config = ProjectAnalytics.new.config
  # 用来交互
  # TODO: 优化点,以后放到其他地方
  config[:gym_config] = ask_gym_build_options if config[:flow_language] == "objc" && ENV["FLOW_CLI_TEST"] != "TRUE"

  str = YamlBuilders::FlowYamlBuilder.init_yaml_builder(config).build_yaml
  raise YamlError, "存在 #{FLOW_YML_NAME}, 删除后才能重新生成" if File.file?(FLOW_YML_NAME)
  File.open(FLOW_YML_NAME, "wb") do |file|
    file.write(str)
  end
  @cmd_helper.echo str
  @cmd_helper.puts_warning "yaml created...\n#{str}"
  @cmd_helper.puts_warning "*" * 20
  @cmd_helper.puts_warning " run 'mv flow.yml .flow.yml && git add .flow.yml' if you know WHAT IS '.flow.yml' "
  @cmd_helper.puts_warning "*" * 20
end

#help(command = nil, subcommand = false) ⇒ Object



67
68
69
70
71
72
# File 'lib/flow/cli/cmd_manager.rb', line 67

def help(command = nil, subcommand = false)
  print_line
  puts @cmd_helper.puts_error("VERSION ALPHA\n Support IOS project ONLY, temporarily.")
  print_line
  super
end

#run_build_scriptObject



40
41
42
43
# File 'lib/flow/cli/cmd_manager.rb', line 40

def run_build_script
  show_build_script
  try_run_yml_build_script
end

#show_build_scriptObject



46
47
48
49
50
51
52
# File 'lib/flow/cli/cmd_manager.rb', line 46

def show_build_script
  script = yml_build_script
  puts @cmd_helper.puts_warning "This is the build script in yaml"
  print_line
  puts script
  print_line
end

#upgradeObject



61
62
63
# File 'lib/flow/cli/cmd_manager.rb', line 61

def upgrade
  run_script "gem install flow-cli"
end

#versionObject



56
57
58
# File 'lib/flow/cli/cmd_manager.rb', line 56

def version
  puts VERSION
end