lib/flow/cli/cmd_manager.rb in flow-cli-0.0.4 vs lib/flow/cli/cmd_manager.rb in flow-cli-0.0.5
- old
+ new
@@ -5,33 +5,30 @@
module Flow::Cli
class CmdManager < Thor
def initialize(*args)
super(*args)
- @prompt = TTY::Prompt.new
- @pastel = Pastel.new
- @error = @pastel.red.bold.detach
- @warning = @pastel.yellow.detach
@db_manager = Utils::DbManager
+ @cmd_helper = Utils::CmdHelper.instance
end
- desc "remote ...ARGS", "manage flow ci"
+ desc "remote ...ARGS", "operations about flow ci."
subcommand "remote", Commands::Remote
desc "build_yaml_file", "build flow ci project yaml"
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 = FlowYamlBuilder.new(config).build_yaml
+ 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
- @warning.call "yaml created...\n#{str}"
+ @cmd_helper.puts_warning "yaml created...\n#{str}"
end
desc "run_build_script", "run flow yml build script"
def run_build_script
show_build_script
@@ -39,11 +36,11 @@
end
desc "show_build_script", "show flow yml build script"
def show_build_script
script = yml_build_script
- puts @warning.call "This is the build script in yaml"
+ puts @cmd_helper.puts_warning "This is the build script in yaml"
print_line
puts script
print_line
end
@@ -60,11 +57,11 @@
desc 'help', 'Describe available commands or one specific command (aliases: `h`).'
map Thor::HELP_MAPPINGS => :help
def help(command = nil, subcommand = false)
print_line
- puts @error.call("VERSION ALPHA\n Support IOS project ONLY, temporarily.")
+ puts @cmd_helper.puts_error("VERSION ALPHA\n Support IOS project ONLY, temporarily.")
print_line
super
end
no_commands do
@@ -94,11 +91,11 @@
cmd.run(script)
end
def yml_build_script
if File.file?(FLOW_YML_NAME) == false
- return unless @prompt.yes?('no flow.yml found, need to build . y/n')
+ return unless @cmd_helper.yes?('no flow.yml found, need to build . y/n')
build_yaml_file
end
scripts = get_scripts(select_yml_steps("build"))
scripts.first if scripts.count > 0
end
@@ -113,11 +110,11 @@
puts "*" * 30
end
def ask_gym_build_options
user_gym_config = {}
- user_gym_config[:export_method] = @prompt.select("export_method? ", %w[development app-store ad-hoc package enterprise developer-id])
- user_gym_config[:silent] = "" if @prompt.yes?("less log?")
+ user_gym_config[:export_method] = @cmd_helper.select("export_method? ", %w[development app-store ad-hoc package enterprise developer-id])
+ user_gym_config[:silent] = "" if @cmd_helper.yes?("less log?")
user_gym_config
end
end
end