bin/tms in tms-1.2.0 vs bin/tms in tms-1.3.0
- old
+ new
@@ -1,47 +1,69 @@
#!/usr/bin/env ruby
-begin
- require 'tms'
-rescue LoadError
- require 'rubygems'
- require 'tms'
-end
-
+require 'tms'
require 'optparse'
def option_parser
- OptionParser.new do |op|
+ @option_parser ||= OptionParser.new do |op|
op.banner = <<-BANNER
+ #{op.program_name}, version #{Tms.version}
+
Usege:
- List: #{op.program_name} [options]
- Diff: #{op.program_name} [options] id|nxxx id|nxxx
- Diff with previous: #{op.program_name} [options] id|nxxx
+ List: #{op.program_name} [options]
+ Diff: #{op.program_name} [options] id|nXXX [id|nXXX]
BANNER
- op.on('-d', '--directory DIRECTORY', 'Use backup directory') do |dir|
- Tms::Backup.backups_dir = dir
+ op.on('-d', '--directory DIRECTORY', 'Use backup directory') do |backups_dir|
+ Tms::Backup.backups_dir = backups_dir
end
- op.on('-f', '--filter DIRECTORY', 'Show diff starting from directory') do |dir|
- Tms::Backup.filter_dir = dir
+ op.on('-f', '--filter DIRECTORY', 'Show diff starting from directory', ' (can be used multiple times)') do |filter_dir|
+ Tms::Backup.add_filter_dir(filter_dir)
end
- op.on('-p', '--[no-]progress', 'Show backups in progress') do |show_in_progress|
+ op.on('-i', '--[no-]in-progress', 'Show backups in progress',
+ ' (note: some directories will be',
+ ' empty in unfinished backups)') do |show_in_progress|
Tms::Backup.show_in_progress = show_in_progress
end
op.on('-l', '--[no-]long', 'Show more info about backup in list') do |show_all_columns|
Tms::Backup.show_all_columns = show_all_columns
end
+
+ op.on('--[no-]color', 'Use color', ' (true by default if stdout is a tty)') do |colorize|
+ Tms::Backup.colorize = colorize
+ end
+
+ op.on('--[no-]progress', 'Show progress when counting folder size', ' (true by default if stderr is a tty)') do |show_progress|
+ Tms::Backup.show_progress = show_progress
+ end
+
+ op.on('--[no-]decimal', 'Use base 10 size') do |use_decimal|
+ Tms::Space.base10 = use_decimal
+ end
+
+ op.on_tail('-h', '--help', 'Show this message') do
+ puts op.help
+ exit
+ end
+
+ op.on_tail('--version', 'Show version') do
+ puts Tms.version
+ exit
+ end
end
end
-options, ids = ARGV.partition{ |arg| arg =~ /^--?\D/ }
+ids, options = ARGV.partition{ |arg| arg =~ /^[\-n]?\d+$/ }
begin
option_parser.parse!(options)
-rescue OptionParser::InvalidOption => e
- abort e
+rescue OptionParser::ParseError => e
+ abort "#{e.to_s}\n#{option_parser.help}"
+end
+unless options.empty?
+ abort "Unknown arguments: #{options.join(' ')}"
end
case ids.length
when 0
Tms.list