diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-08-31 16:10:21 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-08-31 16:10:21 +0300 |
commit | 51daf620008519af565b38f5cd6b3e624741bfef (patch) | |
tree | 1ca6a8d15a0ce17b4f4f7b423a8a0aff91a252c8 | |
parent | 06138afc98740fe9ae5b76a78e39b07d12b7d38f (diff) | |
download | rex-51daf620008519af565b38f5cd6b3e624741bfef.tar.gz rex-51daf620008519af565b38f5cd6b3e624741bfef.tar.bz2 |
Simplify listgroups; reorder debug levels
-rwxr-xr-x | rex.exp | 40 |
1 files changed, 19 insertions, 21 deletions
@@ -691,21 +691,19 @@ namespace eval description { # List available host groups. proc listgroups {} { global confpath argv0 + set first 1 - set groups {} foreach dir $confpath { foreach file [glob -nocomplain -directory $dir -types f "*/rc"] { - set groups [lappend groups [string range $file 0 end-3]] - } - } - if [llength $groups] { - puts "$argv0: use '$argv0 -g GROUP' to select a host group." - puts "$argv0: available host groups are:" - foreach grp $groups { - set i [string last "/" $grp] - set name [string range $grp [expr $i + 1] end] - set descr [::description::get $grp] - puts [format "%-16.16s %s" $name $descr] + if $first { + puts "$argv0: use '$argv0 -g GROUP' to select a host group." + puts "$argv0: available host groups are:" + set first 0 + } + set groupdir [file dirname $file] + puts [format "%-16.16s %s" \ + [file tail $groupdir] \ + [::description::get $groupdir]] } } } @@ -1110,7 +1108,7 @@ proc runcmd {hosts command} { spawn -noecho ssh [hostuser $host]@$host lappend sidlist $spawn_id set sidinfo($spawn_id,host) $host - debug 2 "$host on $spawn_id" + debug 3 "$host on $spawn_id" set sidinfo($spawn_id,state) INIT set sidinfo($spawn_id,zsh-quirk) [config_option zsh-quirk] set sidinfo($spawn_id,earlycmd) [hostearlycmd $host] @@ -1200,23 +1198,23 @@ proc runcmd {hosts command} { -re $config(prompt) { set sid $expect_out(spawn_id) - debug 2 "STATE $sid $sidinfo($sid,state)" + debug 3 "STATE $sid $sidinfo($sid,state)" if {$sidinfo($sid,state) == "INIT" || $sidinfo($sid,state) == "PASS_SENT"} { set cmd [lshift sidinfo($sid,cmdlist)] - debug 2 "$sid: sending $cmd" + debug 3 "$sid: sending $cmd" send -i $sid "$cmd\r" set sidinfo($sid,state) STTY } elseif {$sidinfo($sid,state) == "STTY"} { if [llength $sidinfo($sid,cmdlist)] { set cmd [lshift sidinfo($sid,cmdlist)] - debug 2 "$sid: sending $cmd" + debug 3 "$sid: sending $cmd" send -i $sid "$cmd\r" } elseif [info exists config(data)] { set host $sidinfo($sid,host) set cmd $config(data) lappend cmd "[hostuser $host]@$host:$sidinfo($sid,wd)" - debug 2 "$sid: starting scp $cmd" + debug 3 "$sid: starting scp $cmd" eval spawn -noecho scp $cmd lappend sidlist $spawn_id set sidinfo($spawn_id,state) COPY @@ -1224,7 +1222,7 @@ proc runcmd {hosts command} { set sidinfo($spawn_id,cmd) "scp $cmd" set sidinfo($spawn_id,master) $sid } else { - debug 2 "$sid: sending $command" + debug 3 "$sid: sending $command" send -i $sid "$command\r" set sidinfo($sid,state) COMMAND @@ -1235,7 +1233,7 @@ proc runcmd {hosts command} { } else { if {[info exists sidinfo($sid,wd)] && $sidinfo($sid,state) == "COMMAND"} { set host $sidinfo($sid,host) - debug 2 "$sid: removing $host:$sidinfo($sid,wd)" + debug 3 "$sid: removing $host:$sidinfo($sid,wd)" send -i $sid "$config(sudo)rm -r $sidinfo($sid,wd)\r" if {$config(sudo) != ""} { set sidinfo($sid,state) SUDO2 @@ -1281,8 +1279,8 @@ proc runcmd {hosts command} { closeproc $sid wait -i $sid } elseif {$sidinfo($sid,state) == "COPY"} { - debug 2 "$sidinfo($sid,cmd) finished" - debug 2 "sending $command to $sidinfo($sid,master)" + debug 3 "$sidinfo($sid,cmd) finished" + debug 3 "sending $command to $sidinfo($sid,master)" send -i $sidinfo($sid,master) "$command\r" set sidinfo($sidinfo($sid,master),state) COMMAND |