Class: EasyAI::Command::Utils::Encry
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) ⇒ Encry
Returns a new instance of Encry.
36
37
38
39
40
|
# File 'lib/easyai/command/utils/encry.rb', line 36
def initialize(argv)
@file_path = argv.shift_argument
@output_path = argv.option('output') || argv.shift_argument
super
end
|
Class Method Details
.options ⇒ Object
30
31
32
33
34
|
# File 'lib/easyai/command/utils/encry.rb', line 30
def self.options
[
['--output=PATH', '指定加密后文件的输出路径'],
].concat(super)
end
|
Instance Method Details
#run ⇒ Object
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/easyai/command/utils/encry.rb', line 48
def run
if File.file?(@file_path)
encrypt_file_mode
elsif File.directory?(@file_path)
encrypt_directory_mode
else
puts "❌ 指定路径既不是文件也不是目录: #{@file_path}"
exit 1
end
end
|
#validate! ⇒ Object
42
43
44
45
46
|
# File 'lib/easyai/command/utils/encry.rb', line 42
def validate!
super
help! '请指定要加密的文件或目录路径' if @file_path.nil? || @file_path.empty?
help! "路径不存在: #{@file_path}" unless File.exist?(@file_path)
end
|