Class: Pindo::Command::Appstore::Initconfig
- Inherits:
-
Pindo::Command::Appstore
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Appstore
- Pindo::Command::Appstore::Initconfig
- Defined in:
- lib/pindo/command/appstore/initconfig.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) ⇒ Initconfig
constructor
A new instance of Initconfig.
- #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) ⇒ Initconfig
Returns a new instance of Initconfig.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/pindo/command/appstore/initconfig.rb', line 62 def initialize(argv) # 首先获取位置参数(向后兼容) positional_bundleid = argv.shift_argument # 获取 test 标志 @test_flag = argv.flag?('test', false) # 使用 Options 模块初始化参数 @options = (argv) # 优先使用选项参数,如果没有则使用位置参数 @bundle_id = @options[:bundleid] || positional_bundleid super @additional_args = argv.remainder! end |
Class Method Details
.option_items ⇒ Object
定义此命令使用的参数项
51 52 53 |
# File 'lib/pindo/command/appstore/initconfig.rb', line 51 def self.option_items @option_items ||= Pindo::Options::BuildOptions.select(:bundleid) end |
.options ⇒ Object
命令的选项列表
56 57 58 59 60 |
# File 'lib/pindo/command/appstore/initconfig.rb', line 56 def self. [ ['--test', '创建测试环境仓库'] ].concat(option_items.map { |item| item.to_claide_option }).concat(super) end |
Instance Method Details
#run ⇒ Object
93 94 95 96 97 98 99 100 |
# File 'lib/pindo/command/appstore/initconfig.rb', line 93 def run # 使用 BuildInfoManager 创建配置仓库 build_info_manager = Pindo::BuildInfoManager.share_instance build_info_manager.create_appconfig_with_bundleid( bundle_id: @bundle_id, test_flag: @test_flag ) end |
#validate! ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/pindo/command/appstore/initconfig.rb', line 79 def validate! super # 如果没有提供 bundleid,提示用户输入 if @bundle_id.nil? || @bundle_id.empty? require 'highline/import' cli = HighLine.new say "需要输入仓库名称,默认以 Bundle ID 作为仓库名称" @bundle_id = cli.ask('请输入 Bundle ID: ') end help! '需要提供 Bundle ID' if @bundle_id.nil? || @bundle_id.empty? end |