Class: Pindo::Command::Ios::Autobuild
- Inherits:
-
Pindo::Command::Ios
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Ios
- Pindo::Command::Ios::Autobuild
- Defined in:
- lib/pindo/command/ios/autobuild.rb
Constant Summary
Constants inherited from Pindo::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes inherited from Pindo::Command
Class Method Summary collapse
-
.option_items ⇒ Object
定义此命令使用的参数项(类方法,避免重复定义).
-
.options ⇒ Object
命令的选项列表.
-
.use_cache? ⇒ Boolean
启用缓存机制.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Autobuild
constructor
A new instance of Autobuild.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Pindo::Command
command_name, #initialize_options, run
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
Methods included from Githelper
#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #git_root_directory, #is_git_directory?, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag
Methods included from Executable
capture_command, #executable, execute_command, popen3, reader, which, which!
Constructor Details
#initialize(argv) ⇒ Autobuild
Returns a new instance of Autobuild.
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/pindo/command/ios/autobuild.rb', line 96 def initialize(argv) # 先提取 build_type(因为 bundleid 的 value_block 需要用到它) @build_type = argv.option('build_type', 'dev') # 一行代码完成参数初始化(自动推导命令名、自动启用缓存) @options = (argv) # 保存参数到实例变量 @build_type = @options[:build_type] || @build_type # 使用 options 中的值,如果没有则用之前提取的 @args_send_flag = @options[:send] # send 依赖 upload:如果指定了 send,自动启用 upload @args_upload_flag = @options[:send] || @options[:upload] @args_proj_name = @options[:proj] @args_bundle_id = @options[:bundleid] super @additional_args = argv.remainder! end |
Class Method Details
.option_items ⇒ Object
定义此命令使用的参数项(类方法,避免重复定义)
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/pindo/command/ios/autobuild.rb', line 69 def self.option_items @option_items ||= begin items = Pindo::Options::OptionGroup.merge( Pindo::Options::BuildOptions.select(:bundleid, :build_type), Pindo::Options::JPSOptions.select(:proj, :upload, :send) ) # 为 bundleid 参数添加 value_block(交互式选择) bundleid_item = items.find { |item| item.key == :bundleid } if bundleid_item bundleid_item.value_block = proc do |command_instance| # 根据构建类型选择不同的 Bundle ID build_type = command_instance.instance_variable_get(:@build_type) || 'dev' Pindo::Options::BundleIdSelector.select_bundleid(build_type) end end items end end |
.options ⇒ Object
命令的选项列表
91 92 93 94 |
# File 'lib/pindo/command/ios/autobuild.rb', line 91 def self. # 转换为 CLAide 格式 option_items.map { |item| item.to_claide_option }.concat(super) end |
.use_cache? ⇒ Boolean
启用缓存机制
28 29 30 |
# File 'lib/pindo/command/ios/autobuild.rb', line 28 def self.use_cache? true # 此命令启用缓存 end |
Instance Method Details
#run ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/pindo/command/ios/autobuild.rb', line 120 def run pindo_project_dir = Dir.pwd begin # 加载 JPS 配置(如果存在) context = Pindo::PindoContext.instance context.load_and_apply_jps_config(pindo_project_dir) # 注意:参数缓存已在 initialize 中通过 GlobalOptionsState 处理 # 不再使用 PindoContext 的缓存机制 # 准备配置 config = prepare_ios_config(pindo_project_dir) # 创建并执行任务 tasks = make_build_task(config) # 添加到任务管理器并执行 task_manager = Pindo::TaskSystem::TaskManager.instance task_manager.clear_all tasks.each { |task| task_manager.add_task(task) } task_manager.start system "open #{pindo_project_dir}" ensure # 清除命令状态(如果启用了缓存,这里会自动保存) Pindo::Options::GlobalOptionsState.instance.clear end end |
#validate! ⇒ Object
115 116 117 118 |
# File 'lib/pindo/command/ios/autobuild.rb', line 115 def validate! super end |