Class: ServerStatus::Application
- Inherits:
-
Object
- Object
- ServerStatus::Application
- Includes:
- Commander::Methods
- Defined in:
- lib/server-status/application.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
Instance Method Summary collapse
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #run ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
8 9 10 |
# File 'lib/server-status/application.rb', line 8 def initialize @config = ServerStatus::Configuration.new end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/server-status/application.rb', line 5 def configuration @configuration end |
Instance Method Details
#run ⇒ Object
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/server-status/application.rb', line 12 def run never_trace! program :name, 'Server Status' program :version, ServerStatus::VERSION program :description, 'Fast remote host statuses' default_command :run command :run do |c| c.description = 'Fetch statuses of all tracked hosts (default)' c.option '--[no-]os' c.option '--[no-]uptime' c.option '--[no-]load' c.option '--[no-]disk-usage' c.option '--[no-]inode-usage' c.option '--[no-]memory-usage' c.option '--[no-]clock-drift' c.option '--[no-]package-updates' c.option '--[no-]reboot-required' c.action do |args, | .default({ os: false, uptime: true, load: true, disk: true, inode: true, memory: true, clock_drift: true, pkg_updates: true, reboot_required: false }.merge(@config.)) ServerStatus::Commands::Run.new(@config, ).perform end end command :list do |c| c.description = 'List all currently tracked hosts' c.action do ServerStatus::Commands::List.new(@config).perform end end command :add do |c| c.syntax = 'add <host> [name]' c.description = 'Add a remote host' c.action do |args, | if args.size < 1 || args.size > 2 puts "requires either 1 or 2 arguments\n\n\tadd <host> [friendly-name]\n\n" exit(1) end ServerStatus::Commands::Add.new(@config, *args).perform end end command :remove do |c| c.syntax = 'remove <name>' c.description = 'Remove a remote host' c.action do |args, | unless args.size == 1 puts "requires 1 argument\n\n\tremove <name>\n\n" exit(1) end ServerStatus::Commands::Remove.new(@config, *args).perform end end run! end |