Class: Pindo::Command::Appstore::Pullconfig

Inherits:
Pindo::Command::Appstore show all
Defined in:
lib/pindo/command/appstore/pullconfig.rb

Constant Summary

Constants inherited from Pindo::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes inherited from Pindo::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Pindo::Command

command_name, #initialize_options, run, use_cache?

Methods included from Funlog::Mixin

#pindo_log_instance

Methods included from Pindoconfig::Mixin

#pindo_single_config

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) ⇒ Pullconfig

Returns a new instance of Pullconfig.



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/pindo/command/appstore/pullconfig.rb', line 59

def initialize(argv)
    # 首先获取位置参数(向后兼容)
    positional_bundleid = argv.shift_argument

    # 使用 Options 模块初始化参数
    @options = initialize_options(argv)

    # 优先使用选项参数,如果没有则使用位置参数
    @args_appconfig_repo_name = @options[:bundleid] || positional_bundleid

    super
    @additional_args = argv.remainder!
end

Class Method Details

.option_itemsObject

定义此命令使用的参数项



49
50
51
# File 'lib/pindo/command/appstore/pullconfig.rb', line 49

def self.option_items
    @option_items ||= Pindo::Options::BuildOptions.select(:bundleid)
end

.optionsObject

命令的选项列表



54
55
56
57
# File 'lib/pindo/command/appstore/pullconfig.rb', line 54

def self.options
    # 转换为 CLAide 格式
    option_items.map { |item| item.to_claide_option }.concat(super)
end

Instance Method Details

#runObject



87
88
89
90
91
92
93
94
# File 'lib/pindo/command/appstore/pullconfig.rb', line 87

def run
    # 使用 BuildInfoManager 拉取配置
    build_info_manager = Pindo::BuildInfoManager.share_instance
    build_info_manager.pull_appconfig_with_reponame(
        repo_name: @args_appconfig_repo_name,
        target_dir: Dir.pwd
    )
end

#validate!Object



73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/pindo/command/appstore/pullconfig.rb', line 73

def validate!
    super

    # 如果没有提供 bundleid,提示用户输入
    if @args_appconfig_repo_name.nil? || @args_appconfig_repo_name.empty?
        require 'highline/import'
        cli = HighLine.new
        say "需要指定 Bundle ID"
        @args_appconfig_repo_name = cli.ask('请输入 Bundle ID: ')
    end

    help! '需要提供 Bundle ID' if @args_appconfig_repo_name.nil? || @args_appconfig_repo_name.empty?
end