Module: Sparoid::CLI
- Defined in:
- lib/sparoid/cli.rb
Overview
CLI
Class Method Summary collapse
-
.run(args = ARGV) ⇒ Object
rubocop:disable Metrics/AbcSize.
Class Method Details
.run(args = ARGV) ⇒ Object
rubocop:disable Metrics/AbcSize
9 10 11 12 13 14 15 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 |
# File 'lib/sparoid/cli.rb', line 9 def self.run(args = ARGV) # rubocop:disable Metrics/AbcSize subcommand = args.shift host = "0.0.0.0" port = 8484 tcp_port = 22 config_path = "~/.sparoid.ini" case subcommand when "keygen" Sparoid.keygen when "send" (args, binding) key, hmac_key = read_keys(config_path) Sparoid.auth(key, hmac_key, host, port) when "connect" (args, binding) key, hmac_key = read_keys(config_path) ips = Sparoid.auth(key, hmac_key, host, port) Sparoid.fdpass(ips, tcp_port) when "--version" puts Sparoid::VERSION else puts "Usage: sparoid [subcommand] [options]" puts "" puts "Subcommands: keygen, send, connect" puts "Use --version to show version" exit 1 end rescue StandardError => e warn "Sparoid error: #{e.}" exit 1 end |