Class: EasyAI::Command::Clean
Constant Summary
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
#args_help_flag
Class Method Summary
collapse
Instance Method Summary
collapse
run
Constructor Details
#initialize(argv) ⇒ Clean
Returns a new instance of Clean.
40
41
42
43
44
45
|
# File 'lib/easyai/command/clean.rb', line 40
def initialize(argv)
@tool_name = argv.shift_argument || 'claude'
@force = argv.flag?('force')
@dry_run = argv.flag?('dry-run')
super
end
|
Class Method Details
.options ⇒ Object
33
34
35
36
37
38
|
# File 'lib/easyai/command/clean.rb', line 33
def self.options
[
['--force', '强制清理,不询问确认'],
['--dry-run', '预览将要清理的项目,不执行实际清理'],
].concat(super)
end
|
Instance Method Details
#run ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/easyai/command/clean.rb', line 56
def run
puts "🧹 准备清理 #{@tool_name == 'all' ? '所有AI工具' : @tool_name.upcase} 的配置信息"
puts
if @dry_run
puts "📋 预览模式 - 以下项目将被清理:"
preview_cleanup
return
end
unless @force
puts "⚠️ 警告:此操作将删除以下配置信息:"
preview_cleanup
puts
print "确认继续清理?(y/N): "
confirmation = STDIN.gets.chomp.downcase
unless confirmation == 'y' || confirmation == 'yes'
puts "❌ 清理操作已取消"
return
end
end
puts "🧹 开始清理配置..."
perform_cleanup
puts "✅ 清理完成"
end
|
#validate! ⇒ Object
47
48
49
50
51
52
53
54
|
# File 'lib/easyai/command/clean.rb', line 47
def validate!
super
valid_tools = %w[claude gemini openai all]
unless valid_tools.include?(@tool_name.downcase)
help! "不支持的工具名称: #{@tool_name}。支持的工具: #{valid_tools.join(', ')}"
end
@tool_name = @tool_name.downcase
end
|