Class: Switchboard::Commands::Default
- Inherits:
-
Switchboard::Command
- Object
- Switchboard::Command
- Switchboard::Commands::Default
- Defined in:
- lib/switchboard/commands/default.rb
Constant Summary
Constants inherited from Switchboard::Command
Switchboard::Command::DEFAULT_OPTIONS, Switchboard::Command::OPTIONS
Class Method Summary collapse
Methods inherited from Switchboard::Command
description, help, to_command, to_command_name
Class Method Details
.options(opts) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/switchboard/commands/default.rb', line 15 def self.(opts) super(opts) opts. = "Usage: #{opts.program_name} [options] COMMAND [options] [args]" # opts.on("-d", "--daemon", "Make server run as a daemon.") { OPTIONS[:detach] = true } opts.on("-j", "--jid=jid", String, "Specifies the JID to use.") { |v| OPTIONS["jid"] = v } opts.on("-r", "--resource=resource", String, "Specifies the resource to use.") { |v| OPTIONS["resource"] = v } opts.on("-p", "--password=password", String, "Specifies the password to use.") { |v| OPTIONS["password"] = v } # opts.on("-p", "--pidfile=path", String, # "Specifies a pidfile to use.") { |v| OPTIONS[:pidfile] = v } # opts.on("-v", "--[no-]verbose", "Run verbosely") { |v| OPTIONS[:verbose] = v } opts.separator "" opts.on_tail("-h", "--help", "Show this help message.") { puts opts; exit } opts.on_tail("--version", "Show version") { puts "switchboard version #{Switchboard::VERSION * "."}"; exit } end |
.run! ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/switchboard/commands/default.rb', line 34 def self.run! puts self.(OptionParser.new).help puts puts "Available commands:" Switchboard.commands.each do |name, command| puts " #{command.to_command.ljust(15)}#{command.description}" command.(OptionParser.new).summarize do |line| puts " " * 16 + line end end puts puts "See '#{@options.program_name} help COMMAND' for more information on a specific command." end |