Class: Pindo::Command::Utils::Installskills

Inherits:
Pindo::Command::Utils show all
Defined in:
lib/pindo/command/utils/installskills.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 HelpValidator

#validate!

Constructor Details

#initialize(argv) ⇒ Installskills

Returns a new instance of Installskills.



38
39
40
41
42
43
44
# File 'lib/pindo/command/utils/installskills.rb', line 38

def initialize(argv)
  @skill_names = argv.arguments! || []
  @source = argv.option('source')

  super
  @additional_args = argv.remainder!
end

Class Method Details

.optionsObject



32
33
34
35
36
# File 'lib/pindo/command/utils/installskills.rb', line 32

def self.options
  [
    ['--source=URL', '指定技能仓库地址,指定后跳过仓库选择'],
  ].concat(super)
end

Instance Method Details

#runObject



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/pindo/command/utils/installskills.rb', line 46

def run
  # 确定使用的仓库
  repo_info = determine_repo
  return if repo_info.nil?

  # 克隆仓库到临时目录
  temp_dir = clone_repo_to_temp(repo_info)
  return if temp_dir.nil?

  begin
    # 安装 command 和 skills
    install_from_repo(temp_dir, repo_info['skills_repo_name'] || 'custom')
  ensure
    # 清理临时目录
    FileUtils.rm_rf(temp_dir) if File.exist?(temp_dir)
  end
end