Class: Specter::Cli
- Inherits:
-
Object
- Object
- Specter::Cli
- Defined in:
- lib/specter/cli.rb
Constant Summary collapse
- DEFAULT_HOST =
'0.0.0.0'
- DEFAULT_PORT =
5028
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Cli
constructor
A new instance of Cli.
- #output_header ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Cli
Returns a new instance of Cli.
13 14 15 16 |
# File 'lib/specter/cli.rb', line 13 def initialize(argv) @argv = argv @options = {} end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/specter/cli.rb', line 11 def @options end |
Class Method Details
.start(argv) ⇒ Object
18 19 20 |
# File 'lib/specter/cli.rb', line 18 def self.start(argv) new(argv).run end |
Instance Method Details
#output_header ⇒ Object
22 23 24 25 26 27 |
# File 'lib/specter/cli.rb', line 22 def output_header puts "Booting Specter v#{VERSION}..." puts "* Running in #{RUBY_DESCRIPTION}" puts "* Listening on tcp://#{[:host]}:#{[:port]}" puts 'Use Ctrl-C to stop' end |
#run ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/specter/cli.rb', line 29 def run output_header @thread = @server.run @thread.run Signal.trap('INT') do puts 'Stopping...' @thread.exit exit end @thread.join end |