41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/pxcbackup/application.rb', line 41
def parse_options(argv)
@options ||= {}
parser = OptionParser.new do |opt|
opt.banner = "Usage: #{$0} COMMAND [OPTIONS]"
opt.separator ''
opt.separator 'Commands'
opt.separator ' create create a new backup'
opt.separator ' help show this help'
opt.separator ' list list available backups'
opt.separator ' restore [time] restore to a point in time'
opt.separator ''
opt.separator 'Options'
opt.on('-c', '--config', '=CONFIG_FILE', 'config file to use instead of ~/.pxcbackup') do |config_file|
@options[:config] = config_file
end
opt.on('-d', '--dir', '=BACKUP_DIR', 'local repository to store backups') do |backup_dir|
@options[:backup_dir] = backup_dir
end
opt.on('-f', '--full', 'create a full backup') do
@options[:type] = :full
end
opt.on('-i', '--incremental', 'create an incremental backup') do
@options[:type] = :incremental
end
opt.on('-l', '--local', 'stay local, i.e. do not communicate with S3') do
@options[:local] = true
end
opt.on('--no-color', 'disable color output') do
@options[:no_color] = true
end
opt.on('-r', '--remote', '=REMOTE_URI', 'remote URI to sync backups to, e.g. s3://my-aws-bucket/') do |remote|
@options[:remote] = remote
end
opt.on('-v', '--verbose', 'verbose output') do
Logger.raise_verbosity
end
opt.on('--version', 'print version and exit') do
puts "pxcbackup #{VERSION}"
exit
end
opt.on('-y', '--yes', 'skip confirmation on backup restore') do
@options[:skip_confirmation] = true
end
end
begin
@command, *@arguments = parser.parse(argv)
if @command == 'help'
puts parser
exit
end
raise 'no command given' if @command.to_s == ''
raise "invalid command #{@command}" unless ['create', 'list', 'restore'].include?(@command)
rescue => e
abort "#{$0}: #{e.message}\n#{parser}"
end
end
|