Class: EasyAI::Command

Inherits:
CLAide::Command
  • Object
show all
Defined in:
lib/easyai/command.rb,
lib/easyai/command/clean.rb,
lib/easyai/command/codex.rb,
lib/easyai/command/setup.rb,
lib/easyai/command/utils.rb,
lib/easyai/command/backup.rb,
lib/easyai/command/claude.rb,
lib/easyai/command/gemini.rb,
lib/easyai/command/update.rb,
lib/easyai/command/restore.rb,
lib/easyai/command/utils/decry.rb,
lib/easyai/command/utils/encry.rb,
lib/easyai/command/ai_tool_base.rb,
lib/easyai/command/backup/claude.rb,
lib/easyai/command/restore/claude.rb

Direct Known Subclasses

AIToolBase, Backup, Clean, Restore, Setup, Update, Utils

Defined Under Namespace

Classes: AIToolBase, Backup, Claude, Clean, Codex, Gemini, Restore, Setup, Update, Utils

Constant Summary collapse

DEFAULT_ROOT_OPTIONS =

根命令的选项

[
  ['--version', '显示版本信息']
]
DEFAULT_OPTIONS =

所有命令通用的选项

[
  ['--help', '显示此帮助信息']
]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Command

Returns a new instance of Command.



38
39
40
41
42
# File 'lib/easyai/command.rb', line 38

def initialize(argv)
  super
  # 使用CLAide已经设置的help_arg,而不是重新获取
  @args_help_flag = @help_arg
end

Instance Attribute Details

#args_help_flagObject Also known as: args_help_flag?

定义帮助标志访问器(类似 pindo)



16
17
18
# File 'lib/easyai/command.rb', line 16

def args_help_flag
  @args_help_flag
end

Class Method Details

.optionsObject



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

def self.options
  if self == Command  # 根命令
    DEFAULT_ROOT_OPTIONS + DEFAULT_OPTIONS
  else  # 子命令
    DEFAULT_OPTIONS
  end
end

.run(argv) ⇒ Object



49
50
51
# File 'lib/easyai/command.rb', line 49

def self.run(argv)
  super(argv)
end

Instance Method Details

#validate!Object



44
45
46
47
# File 'lib/easyai/command.rb', line 44

def validate!
  super
  help! if args_help_flag?
end