Small fixes/changes/updates.

* %-bars swaped from left to right.
* fix qm: ct_cli -> qm.
* ct conf aliased: pvecli ct cnf
* conf set: no shortcut anymore (s and se)
This commit is contained in:
Denis Knauf 2021-09-27 16:07:08 +02:00
parent c7c9bf4800
commit db6e06c1ef
5 changed files with 20 additions and 18 deletions

View file

@ -1,7 +1,7 @@
PATH
remote: .
specs:
pve (0.1.1)
pve (0.1.3)
activesupport (>= 2)
dencli (~> 0.3.1)
ipaddress (~> 0.8.3)
@ -11,26 +11,26 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (6.1.3.1)
activesupport (6.1.4.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
concurrent-ruby (1.1.8)
concurrent-ruby (1.1.9)
dencli (0.3.1)
diff-lcs (1.4.4)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
http-accept (1.7.0)
http-cookie (1.0.3)
http-cookie (1.0.4)
domain_name (~> 0.5)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
ipaddress (0.8.3)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0225)
mime-types-data (3.2021.0901)
minitest (5.14.4)
netrc (0.11.0)
pmap (1.1.1)
@ -56,7 +56,7 @@ GEM
concurrent-ruby (~> 1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
unf_ext (0.0.8)
zeitwerk (2.4.2)
PLATFORMS

View file

@ -86,13 +86,7 @@ def cli_base
cli.sub :config, "CT/VM Configuration", min: 2, aliases: %w[cnf] do |ccli|
ccli.cmd 'help', '', aliases: [nil, '-h', '--help'], &lambda {|*args| help ccli, *args }
ccli.cmd :show, "Show Config of CT/VM", &lambda {|name_or_id|
connect
th = Proxmox::LXC.find( name_or_id) || Proxmox::Qemu.find_by_name( name_or_id)
show_config th.config
}
ccli.cmd :set, "Set Configs for CT/VM", &lambda {|name_or_id, *args|
ccli.cmd :set, "Set Configs for CT/VM", min: 3, &lambda {|name_or_id, *args|
if %w[-h --help].include? name_or_id
STDERR.puts "Usage: set -h|--help # Show help"
STDERR.puts " set ct|vm --CNF1=VAL1 --CNF2=VAL2 ... # Set config-value. Empty value clears field."
@ -149,6 +143,12 @@ def cli_base
th.cnfset opts
show_config th.config, old
}
ccli.cmd :show, "Show Config of CT/VM", aliases: %w[s], &lambda {|name_or_id|
connect
th = Proxmox::LXC.find( name_or_id) || Proxmox::Qemu.find_by_name( name_or_id)
show_config th.config
}
end
cli.cmd :enter, "Enter Console of CT/Node", &lambda {|name_or_id|

View file

@ -99,10 +99,10 @@ EOU
create Proxmox::LXC, template, **ctopts
})
ct_cli.cmd( :config, 'Shows current config', &lambda {|name_or_id|
ct_cli.cmd( :config, 'Shows current config', aliases: %w[cnf], &lambda {|name_or_id|
connect
ct = Proxmox::LXC.find! name_or_id
STDOUT.puts ct.config.to_json
STDOUT.puts JSON.dump( ct.config)
})
ct_cli.cmd( :resize, 'Resize a disk', &lambda {|name_or_id, disk, size|

View file

@ -26,7 +26,7 @@ def cli_qm
STDERR.puts "! #{$?.exitstatus}" unless Proxmox::Qemu.find!( name_or_id).exec *command
}
ct_cli.cmd( :resize, 'Resize a disk', &lambda {|name_or_id, disk, size|
qm.cmd( :resize, 'Resize a disk', &lambda {|name_or_id, disk, size|
connect
qm = Proxmox::Qemu.find! name_or_id
task = qm.resize disk, size

View file

@ -112,10 +112,12 @@ class TablizedOutput
def inspect() "#<TO:Percentage #{@v}%>" end
def to_s
y = w - (v*w).round
#y = w - (v*w).round
y = (v*w).round
x = (100*v).round
r = "%*s" % [w, 0==x ? '·' : x]
"\e[0m#{r[0...y]}\e[1;4;#{0.75>v ? 32 : 31}m#{r[y..-1]}\e[0m"
#"\e[0m#{r[0...y]}\e[1;4;#{0.75>v ? 32 : 31}m#{r[y..-1]}\e[0m"
"\e[1;4;#{0.75>v ? 32 : 31}m#{r[0...y]}\e[0m#{r[y..-1]}"
end
end