Class: OsCtl::Cli::Top::Main
- Inherits:
-
Command
- Object
- Lib::Cli::Command
- Command
- OsCtl::Cli::Top::Main
show all
- Defined in:
- lib/osctl/cli/top/main.rb
Instance Method Summary
collapse
Methods inherited from Command
#cli_opt, #format_output, #osctld_call, #osctld_fmt, #osctld_open, #osctld_resp, run
Instance Method Details
#start ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/osctl/cli/top/main.rb', line 5
def start
validate_rate
model = Top::Model.new(enable_iostat: opts[:iostat])
model.setup
kwargs = {}
if gopts[:json]
klass = Top::JsonExporter
else
klass = Top::Tui
kwargs = { enable_procs: opts[:processes] }
end
view = klass.new(model, opts[:rate], **kwargs)
view.start
end
|
#validate_rate ⇒ Object
27
28
29
30
31
32
|
# File 'lib/osctl/cli/top/main.rb', line 27
def validate_rate
rate = opts[:rate]
return if rate && rate > 0 && rate.finite?
raise GLI::BadCommandLine, 'rate must be a positive finite number'
end
|