Class: Corrupt::Client
- Inherits:
-
Object
- Object
- Corrupt::Client
- Includes:
- ClientHelpers
- Defined in:
- lib/corrupt/client.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv = ARGV) ⇒ Client
constructor
A new instance of Client.
- #run ⇒ Object
Methods included from ClientHelpers
#error, #output, #take_action!
Constructor Details
#initialize(argv = ARGV) ⇒ Client
Returns a new instance of Client.
7 8 9 10 |
# File 'lib/corrupt/client.rb', line 7 def initialize(argv = ARGV) @argv = argv @options = {} end |
Class Method Details
.run ⇒ Object
12 13 14 |
# File 'lib/corrupt/client.rb', line 12 def self.run new.run end |
Instance Method Details
#run ⇒ Object
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/corrupt/client.rb', line 16 def run input = OptionParser.new do |opts| opts. = "Usage: #{File.basename($0)} [options]" opts.on("--debug", "Turn on debugging output.") do |debug| $DEBUG = @options[:debug] = debug end opts.on("-n <path>", "--new", "Create a new Corrupt application.") do |path| @options[:path] = path end opts.on("-v", "--version", "Print the version.") do |v| output(Corrupt.to_version) exit end end begin @argv << '--help' if @argv.empty? input.parse!(@argv) take_action! rescue OptionParser::InvalidOption => error error("#{error}\nTry passing '--help'") rescue OptionParser::MissingArgument => error error("#{error}\nTry passing '--help'") end end |