Class: Pindo::Command

Inherits:
CLAide::Command
  • Object
show all
Includes:
Funlog::Mixin, Githelper, Pindoconfig::Mixin
Defined in:
lib/pindo/command.rb,
lib/pindo/command/env.rb,
lib/pindo/command/ios.rb,
lib/pindo/command/jps.rb,
lib/pindo/command/web.rb,
lib/pindo/command/repo.rb,
lib/pindo/command/gplay.rb,
lib/pindo/command/setup.rb,
lib/pindo/command/unity.rb,
lib/pindo/command/utils.rb,
lib/pindo/command/deploy.rb,
lib/pindo/command/android.rb,
lib/pindo/command/web/run.rb,
lib/pindo/command/appstore.rb,
lib/pindo/command/ios/cert.rb,
lib/pindo/command/jps/bind.rb,
lib/pindo/command/dev/build.rb,
lib/pindo/command/dev/debug.rb,
lib/pindo/command/gplay/iap.rb,
lib/pindo/command/ios/build.rb,
lib/pindo/command/jps/login.rb,
lib/pindo/command/utils/tag.rb,
lib/pindo/command/deploy/iap.rb,
lib/pindo/command/deploy/pem.rb,
lib/pindo/command/deploy/tag.rb,
lib/pindo/command/jps/resign.rb,
lib/pindo/command/jps/upload.rb,
lib/pindo/command/repo/clone.rb,
lib/pindo/command/repo/login.rb,
lib/pindo/command/utils/boss.rb,
lib/pindo/command/utils/icon.rb,
lib/pindo/command/deploy/cert.rb,
lib/pindo/command/ios/podlint.rb,
lib/pindo/command/ios/podpush.rb,
lib/pindo/command/jps/apptest.rb,
lib/pindo/command/jps/comment.rb,
lib/pindo/command/repo/create.rb,
lib/pindo/command/repo/search.rb,
lib/pindo/command/utils/tgate.rb,
lib/pindo/command/appstore/iap.rb,
lib/pindo/command/deploy/build.rb,
lib/pindo/command/deploy/check.rb,
lib/pindo/command/env/quarkenv.rb,
lib/pindo/command/env/swarkenv.rb,
lib/pindo/command/env/workhard.rb,
lib/pindo/command/gplay/itcapp.rb,
lib/pindo/command/gplay/upload.rb,
lib/pindo/command/ios/applovin.rb,
lib/pindo/command/jps/download.rb,
lib/pindo/command/utils/device.rb,
lib/pindo/command/utils/feishu.rb,
lib/pindo/command/android/build.rb,
lib/pindo/command/deploy/fabric.rb,
lib/pindo/command/deploy/itcapp.rb,
lib/pindo/command/deploy/resign.rb,
lib/pindo/command/dev/autobuild.rb,
lib/pindo/command/ios/autobuild.rb,
lib/pindo/command/ios/podupdate.rb,
lib/pindo/command/web/autobuild.rb,
lib/pindo/options/deployoptions.rb,
lib/pindo/command/deploy/itcinfo.rb,
lib/pindo/command/deploy/quswark.rb,
lib/pindo/command/gplay/metadata.rb,
lib/pindo/command/ios/autoresign.rb,
lib/pindo/command/unity/packinit.rb,
lib/pindo/command/unity/packpush.rb,
lib/pindo/command/utils/repoinit.rb,
lib/pindo/command/utils/xcassets.rb,
lib/pindo/command/appstore/import.rb,
lib/pindo/command/appstore/itcapp.rb,
lib/pindo/command/appstore/upload.rb,
lib/pindo/command/deploy/bundleid.rb,
lib/pindo/command/deploy/quswauth.rb,
lib/pindo/command/env/dreamstudio.rb,
lib/pindo/command/unity/autobuild.rb,
lib/pindo/command/unity/packbuild.rb,
lib/pindo/command/utils/clearcert.rb,
lib/pindo/command/utils/renewcert.rb,
lib/pindo/command/utils/renewproj.rb,
lib/pindo/command/android/keystore.rb,
lib/pindo/command/deploy/reportbug.rb,
lib/pindo/command/deploy/uploadipa.rb,
lib/pindo/command/gplay/pullconfig.rb,
lib/pindo/command/android/autobuild.rb,
lib/pindo/command/appstore/metadata.rb,
lib/pindo/command/deploy/configproj.rb,
lib/pindo/command/deploy/getitcinfo.rb,
lib/pindo/command/deploy/initconfig.rb,
lib/pindo/command/deploy/pullconfig.rb,
lib/pindo/command/deploy/pushconfig.rb,
lib/pindo/command/gplay/screenshots.rb,
lib/pindo/command/android/autoresign.rb,
lib/pindo/command/deploy/confusecode.rb,
lib/pindo/command/deploy/confuseproj.rb,
lib/pindo/command/appstore/adhocbuild.rb,
lib/pindo/command/appstore/autoresign.rb,
lib/pindo/command/deploy/updateconfig.rb,
lib/pindo/command/appstore/screenshots.rb

Direct Known Subclasses

Android, Appstore, Deploy, Dev, Env, Gplay, Ios, Jps, Repo, Setup, Unity, Utils, Web

Defined Under Namespace

Modules: DeployOptions Classes: Android, Appstore, Deploy, Dev, Env, Gplay, Ios, Jps, Repo, Setup, Unity, Utils, Web

Constant Summary collapse

DEFAULT_ROOT_OPTIONS =
[
  ['--version', '查看pindo版本'],
]
DEFAULT_OPTIONS =
[
  ['--help',    '查看命令行用法'],
  ['--verbose', '显示详细的调试信息'],
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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, which, which!

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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
149
150
# File 'lib/pindo/command.rb', line 104

def initialize(argv)
    super
    @args_help_flag = argv.flag?('help', false)
    @args_verbose_flag = argv.flag?('verbose', false)

    # 检查是否是 help 请求(检查原始命令行参数)
    original_args = ARGV.join(' ')
    is_help_request = @args_help_flag ||
                    original_args.include?('--help') ||
                    original_args.include?('-h') ||
                    argv.remainder.include?('--help') ||
                    argv.remainder.include?('-h')

    # 设置全局 verbose 标志
    ENV['PINDO_VERBOSE'] = '1' if @args_verbose_flag

    # 在非抽象命令初始化时设置上下文(但不在显示帮助时)
    if !self.class.abstract_command? && !is_help_request
        context = Pindo::PindoContext.instance

        # 只在上下文未设置时才设置(避免重复设置)
        if context.instance_variable_get(:@current_command).nil?
            # 获取完整的命令路径
            command_parts = []
            current = self.class
            while current < Pindo::Command
                if current.command && current.command != 'pindo'
                    command_parts.unshift(current.command)
                end
                current = current.superclass
            end
            command_name = command_parts.empty? ? self.class.command : command_parts.join(':')

            # 配置选项
            cache_enabled_value = self.class.respond_to?(:use_cache?) ? self.class.use_cache? : false
            options = {
                cache_enabled: cache_enabled_value,
                verbose: @args_verbose_flag
            }

            # 获取项目根目录(Git仓库根目录或当前目录)
            project_dir = get_project_root_directory(Dir.pwd)

            context.set_context(command_name, project_dir, options)
        end
    end
end

Instance Attribute Details

#args_help_flagObject Also known as: args_help_flag?

Returns the value of attribute args_help_flag.



53
54
55
# File 'lib/pindo/command.rb', line 53

def args_help_flag
  @args_help_flag
end

Class Method Details

.optionsObject

].concat(super) end



85
86
87
88
89
90
91
# File 'lib/pindo/command.rb', line 85

def self.options
  if root_command?
    DEFAULT_ROOT_OPTIONS + DEFAULT_OPTIONS
  else
    DEFAULT_OPTIONS
  end
end

.run(argv) ⇒ Object



98
99
100
101
102
# File 'lib/pindo/command.rb', line 98

def self.run(argv)
    # 直接调用父类的 run 方法
    # PindoContext 的设置在 initialize 中处理
    super(argv)
end

.use_cache?Boolean

缓存配置:子类可以重写此方法来启用缓存

Returns:

  • (Boolean)


62
63
64
# File 'lib/pindo/command.rb', line 62

def self.use_cache?
  false  # 默认不使用缓存
end

Instance Method Details

#validate!Object



93
94
95
96
# File 'lib/pindo/command.rb', line 93

def validate!
    super
    help! if args_help_flag?
end