Class: Pindo::Command::Appstore::Itcapp
- Inherits:
-
Pindo::Command::Appstore
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Appstore
- Pindo::Command::Appstore::Itcapp
- Defined in:
- lib/pindo/command/appstore/itcapp.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) ⇒ Itcapp
constructor
A new instance of Itcapp.
- #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
Constructor Details
#initialize(argv) ⇒ Itcapp
Returns a new instance of Itcapp.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/pindo/command/appstore/itcapp.rb', line 84 def initialize(argv) # 首先获取位置参数(向后兼容) positional_config = argv.shift_argument # 使用 Options 模块初始化参数 @options = (argv) # 优先使用选项参数,如果没有则使用位置参数,最后默认为当前目录的config.json @config_path = @options[:config] || positional_config || File.join(Dir.pwd, 'config.json') @app_version = @options[:num] @company_name = @options[:com] puts "@app_version = #{@app_version}" if @app_version super @additional_args = argv.remainder! end |
Class Method Details
.option_items ⇒ Object
定义此命令使用的参数项(类方法,避免重复定义)
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/pindo/command/appstore/itcapp.rb', line 52 def self.option_items @option_items ||= [ Pindo::Options::OptionItem.new( key: :config, description: '指定config.json文件路径', type: String, optional: true, example: 'pindo appstore itcapp --config=config.json' ), Pindo::Options::OptionItem.new( key: :num, description: '指定应用版本号', type: String, optional: true, example: 'pindo appstore itcapp --num=1.0.0' ), Pindo::Options::OptionItem.new( key: :com, description: '指定公司名称', type: String, optional: true, example: 'pindo appstore itcapp --com="My Company"' ) ] end |
.options ⇒ Object
命令的选项列表
79 80 81 82 |
# File 'lib/pindo/command/appstore/itcapp.rb', line 79 def self. # 转换为 CLAide 格式 option_items.map { |item| item.to_claide_option }.concat(super) end |
Instance Method Details
#run ⇒ Object
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/pindo/command/appstore/itcapp.rb', line 118 def run # 调用 ItcAppHelper 执行 iTunes Connect App 创建流程 begin Pindo::ItcAppHelper.execute_itcapp_creation( config_json: @config_json, config_path: @config_path, app_version: @app_version, company_name: @company_name ) puts "\n✓ iTunes Connect App 创建完成!" rescue StandardError => e puts "\n❌ iTunes Connect App 创建失败: #{e.}" raise e end end |
#validate! ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/pindo/command/appstore/itcapp.rb', line 102 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.}" end end |