Class: Corrupt::Client
- Inherits:
-
Object
- Object
- Corrupt::Client
- Includes:
- ClientHelpers
- Defined in:
- lib/corrupt/client.rb
Overview
The Corrupt command-line Client.
Class Method Summary collapse
-
.run ⇒ Object
Class wrapper to the instance method Corrupt::Client#run.
Instance Method Summary collapse
-
#initialize(argv = ARGV) ⇒ Client
constructor
A new instance of Client.
-
#run ⇒ Object
Handles ARGV input from the client.
Methods included from ClientHelpers
#error, #output, #take_action!
Constructor Details
#initialize(argv = ARGV) ⇒ Client
Returns a new instance of Client.
8 9 10 11 |
# File 'lib/corrupt/client.rb', line 8 def initialize(argv = ARGV) @argv = argv @options = {} end |
Class Method Details
.run ⇒ Object
Class wrapper to the instance method Corrupt::Client#run.
14 15 16 |
# File 'lib/corrupt/client.rb', line 14 def self.run new.run end |
Instance Method Details
#run ⇒ Object
Handles ARGV input from the client.
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 44 45 46 |
# File 'lib/corrupt/client.rb', line 19 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 |