Class: EasyAI::Command

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

Direct Known Subclasses

Claude, Clean, GPT, Gemini, Setup, Update, Utils

Defined Under Namespace

Classes: Claude, Clean, GPT, Gemini, 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.



40
41
42
43
44
# File 'lib/easyai/command.rb', line 40

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)



18
19
20
# File 'lib/easyai/command.rb', line 18

def args_help_flag
  @args_help_flag
end

Class Method Details

.optionsObject



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

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

.run(argv) ⇒ Object



51
52
53
# File 'lib/easyai/command.rb', line 51

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

Instance Method Details

#validate!Object



46
47
48
49
# File 'lib/easyai/command.rb', line 46

def validate!
  super
  help! if args_help_flag?
end