diff --git a/lib/pve/cli.rb b/lib/pve/cli.rb index 27f7978..5df303d 100644 --- a/lib/pve/cli.rb +++ b/lib/pve/cli.rb @@ -59,16 +59,18 @@ class PVE::Cli secs ||= 0.1 spinners, spin, logn = "▖▘▝▗", 0, 0 STDERR.puts task.upid + host = task.host&.name loop do s = task.status if s[:exitstatus] - STDERR.printf "\r[%s] %s %s\e[J\n", - task.host ? task.host.name : s[:id], + STDERR.printf "\r[%s] %s %s %s\e[J\n", + host || s[:id], case s[:exitstatus] when "OK" then "\e[32;1m✓\e[0m" else "\e[31;1m✗\e[0m" end, - s[:status] + text && "#{text}:", + s[:status] == 'stopped' ? :finished : s[:status] return task end log = task.log start: logn @@ -78,7 +80,10 @@ class PVE::Cli log.each {|l| puts l[:t] } logn = log.last[:n] end - STDERR.printf "\r[%s] \e[33;1m%s\e[0m %s...\e[J", task.host ? task.host.name : s[:id], spinners[spin = (spin + 1) % 4], text || "Working" + STDERR.printf "\r[%s] \e[33;1m%s\e[0m %s...\e[J", + host || s[:id], + spinners[spin = (spin + 1) % 4], + text || "Working" sleep secs end end @@ -112,12 +117,12 @@ class PVE::Cli end def create klass, template, timeout: nil, fire: nil, secs: nil, start: nil, **options - options[:start] = true if fire and start + options[:start] = fire && start task = klass.create template, **options return if fire wait task, text: "Creating" host = task.host.refresh! - start host, timeout: timeout, secs: secs + start host, timeout: timeout, secs: secs if start end def destroy ct, timeout: nil, fire: nil, secs: nil @@ -151,7 +156,7 @@ class PVE::Cli def call *argv cli.call *argv rescue RestClient::ExceptionWithResponse - STDERR.puts "#$! - #{$!.response} (#{$!.class})", $!.backtrace.map {|b|" #{b}"} + STDERR.puts "#$! - #{$!.response} (#{$!.class})" #, $!.backtrace.map {|b|" #{b}"} rescue UsageError, DenCli::UsageError STDERR.puts $! exit 1 diff --git a/lib/pve/cli/ct.rb b/lib/pve/cli/ct.rb index bee83c0..0d7fded 100644 --- a/lib/pve/cli/ct.rb +++ b/lib/pve/cli/ct.rb @@ -65,9 +65,11 @@ def cli_ct end ctopts = {} OptionParser.new do |opts| + ctt = PVE::CTTemplate.const_get template.classify opts.banner = <