Class: RightScriptSync::CommandLine
- Inherits:
-
Object
- Object
- RightScriptSync::CommandLine
- Defined in:
- lib/rightscript_sync/command_line.rb
Instance Attribute Summary collapse
-
#downloader ⇒ Object
Returns the value of attribute downloader.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize ⇒ CommandLine
constructor
A new instance of CommandLine.
Constructor Details
#initialize ⇒ CommandLine
Returns a new instance of CommandLine.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 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 |
# File 'lib/rightscript_sync/command_line.rb', line 27 def initialize = {} begin @optparse = OptionParser.new do |opts| opts. = "Usage: #{$0} options" [:dry_run] = false opts.on( '--dry-run', 'Output the parsed files to STDOUT' ) do [:dry_run] = true end opts.on( '--output-path DIR', 'Use DIR as output directory') do |dir| [:output_path] = dir.gsub(/\/+$/, '') end opts.on( '--account-id ID', 'RightScale Account ID' ) do|account_id| [:account_id] = account_id end opts.on( '--username USERNAME', 'RightScale Username' ) do|username| [:username] = username end opts.on( '--password PASSWORD', 'RightScale Password' ) do|password| [:password] = password end [:log_level] = Logger::INFO opts.on( '--log-level LEVEL', 'Logging level' ) do|level| [:log_level] = Logger.const_get level.upcase end opts.on( '-V', '--version', 'Display version information' ) do puts "RightScript Sync #{RightScriptSync::VERSION}" puts "Copyright (C) 2012 Erik Osterman <[email protected]>" puts "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>" puts "This is free software: you are free to change and redistribute it." puts "There is NO WARRANTY, to the extent permitted by law." exit end opts.on( '-h', '--help', 'Display this screen' ) do puts opts exit end end @optparse.parse! raise MissingArgumentException.new("Missing --account-id argument") if [:account_id].nil? raise MissingArgumentException.new("Missing --username argument") if [:username].nil? raise MissingArgumentException.new("Missing --password argument") if [:password].nil? raise MissingArgumentException.new("Missing --output-path argument") if [:output_path].nil? @downloader = Downloader.new() rescue MissingArgumentException => e puts e. puts @optparse exit (1) end end |
Instance Attribute Details
#downloader ⇒ Object
Returns the value of attribute downloader.
26 27 28 |
# File 'lib/rightscript_sync/command_line.rb', line 26 def downloader @downloader end |
Instance Method Details
#execute ⇒ Object
90 91 92 |
# File 'lib/rightscript_sync/command_line.rb', line 90 def execute @downloader.execute end |