Class: EasyAI::Command::Setup

Inherits:
EasyAI::Command show all
Defined in:
lib/easyai/command/setup.rb

Constant Summary

Constants inherited from EasyAI::Command

DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS

Instance Attribute Summary

Attributes inherited from EasyAI::Command

#args_help_flag

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from EasyAI::Command

run, #validate!

Constructor Details

#initialize(argv) ⇒ Setup

Returns a new instance of Setup.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/easyai/command/setup.rb', line 40

def initialize(argv)
  @force = argv.flag?('force')
  @branch = argv.option('branch') || 'master'
  @verify_only = argv.flag?('verify')
  @list_users = argv.flag?('list-users')
  @clean = argv.flag?('clean')
  @skip_password = argv.flag?('no-password')
  super

  @config_dir = File.expand_path('~/.easyai')
  @repo_dir = File.join(@config_dir, 'EasyAISetting')
end

Class Method Details

.optionsObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/easyai/command/setup.rb', line 29

def self.options
  [
    ['--force', '强制重新下载配置仓库'],
    ['--branch=BRANCH', '指定配置仓库分支 (默认: master)'],
    ['--verify', '仅验证现有配置,不进行修改'],
    ['--list-users', '列出所有可用用户'],
    ['--clean', '清理所有临时解密文件'],
    ['--no-password', '跳过密码设置'],
  ].concat(super)
end

Instance Method Details

#runObject



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/easyai/command/setup.rb', line 53

def run
  show_welcome_banner

  if @verify_only
    verify_configuration
    return
  end

  if @clean
    cleanup_files
    return
  end

  if @list_users
    show_available_users
    return
  end

  # 执行主要设置流程
  perform_setup

  # 显示完成信息
  show_completion_info
end