Class: Pindo::Command::Appstore::Bundleid
- Inherits:
-
Pindo::Command::Appstore
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Appstore
- Pindo::Command::Appstore::Bundleid
- Defined in:
- lib/pindo/command/appstore/bundleid.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
命令的选项列表.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Bundleid
constructor
A new instance of Bundleid.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Pindo::Command
command_name, #initialize_options, run, use_cache?
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) ⇒ Bundleid
Returns a new instance of Bundleid.
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/pindo/command/appstore/bundleid.rb', line 72 def initialize(argv) # 首先获取位置参数(向后兼容) positional_config = argv.shift_argument # 使用 Options 模块初始化参数 = (argv) # 优先使用选项参数,如果没有则使用位置参数,最后默认为当前目录的config.json @config_path = [:config] || positional_config || File.join(Dir.pwd, 'config.json') @args_sign_flag = [:sign] super @additional_args = argv.remainder! end |
Class Method Details
.option_items ⇒ Object
定义此命令使用的参数项(类方法,避免重复定义)
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/pindo/command/appstore/bundleid.rb', line 46 def self.option_items @option_items ||= [ Pindo::Options::OptionItem.new( key: :config, description: '指定config.json文件路径', type: String, optional: true, example: 'pindo appstore bundleid --config=config.json' ), Pindo::Options::OptionItem.new( key: :sign, description: '启用签名标志', type: TrueClass, optional: true, default_value: false, example: 'pindo appstore bundleid --sign' ) ] end |
.options ⇒ Object
命令的选项列表
67 68 69 70 |
# File 'lib/pindo/command/appstore/bundleid.rb', line 67 def self. # 转换为 CLAide 格式 option_items.map { |item| item.to_claide_option }.concat(super) end |
Instance Method Details
#run ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/pindo/command/appstore/bundleid.rb', line 103 def run # 调用 BundleIdHelper 执行 Bundle ID 创建流程 begin Pindo::BundleIdHelper.execute_bundleid_creation( config_json: @config_json, sign_flag: @args_sign_flag ) puts "\n✓ Bundle ID 创建完成!" rescue StandardError => e puts "\n❌ Bundle ID 创建失败: #{e.message}" raise e end end |
#validate! ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/pindo/command/appstore/bundleid.rb', line 87 def validate! super # 检查 config.json 文件是否存在 unless File.exist?(@config_path) help! "配置文件不存在: #{@config_path}" end # 读取并解析 config.json begin @config_json = JSON.parse(File.read(@config_path)) rescue JSON::ParserError => e help! "配置文件格式错误: #{e.message}" end end |