Class: I18n::Magic::CommandHandler
- Inherits:
-
Object
- Object
- I18n::Magic::CommandHandler
- Defined in:
- lib/i18n/magic.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ CommandHandler
constructor
A new instance of CommandHandler.
Constructor Details
#initialize(args) ⇒ CommandHandler
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/i18n/magic.rb', line 7 def initialize(args) @opt_parser = OptionParser.new do |opt| opt. = 'Usage:' opt.separator ' i18n-magic [command] [options]' opt.separator '' opt.separator 'Options:' opt.on('-h', '--help', '# Show this help message and quit') do puts @opt_parser exit(true) end opt.separator '' opt.on('-v', '--version', '# Show i18n-magic version number and quit') do puts I18n::Magic::VERSION exit(true) end opt.separator '' opt.separator 'Commands:' opt.separator ' add # add a new translation' opt.separator ' server # start a mini server to handle missing translations form a web browser' opt.separator ' format # format all translation files for best usage results' opt.separator ' config # configure i18n-magic' opt.separator '' end begin @opt_parser.parse! rescue OptionParser::InvalidOption puts 'unknown option' exit(false) end handle(args) end |