From d45cab7c042fb4889d9da5dafd8167e135e80e1f Mon Sep 17 00:00:00 2001 From: mdw Date: Sun, 9 Mar 2003 17:59:48 +0000 Subject: [PATCH] Add patterns for printing attributes in elite-cmdr. --- README | 7 +++++-- elite-cmdr | 28 ++++++++++++++++------------ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/README b/README index 62aba1d..ad122ab 100644 --- a/README +++ b/README @@ -283,7 +283,10 @@ RIGHT ON COMMAND-LINE An attribute name on its own is a request to print the current value of that attribute. An assignment ATTR=VALUE makes ATTR - have the requested VALUE. + have the requested VALUE. When requesting attributes, you can + instead give a pattern containing `*' and `?' metacharacters + (matching zero or more, or exactly one character) -- all + matching attributes are printed. The attributes, their meanings, and the acceptable values are as follows: @@ -555,7 +558,7 @@ RIGHT ON COMMAND-LINE unrewarding) or pirates (risky and tedious), and start trading food and other cheap items. -$Id: README,v 1.7 2003/03/07 00:47:13 mdw Exp $ +$Id: README,v 1.8 2003/03/09 17:59:48 mdw Exp $ Local variables: mode: text diff --git a/elite-cmdr b/elite-cmdr index e534158..d75feda 100755 --- a/elite-cmdr +++ b/elite-cmdr @@ -238,19 +238,23 @@ for {set i 0} {$i < [llength $argv]} {incr i} { exit 1 } } - "^[a-z][a-z-]*$" { - if {![info exists attr($a)]} { - puts stderr "$argv0: no such attribute `$a'" - exit 1 - } - puts [format "%-20s %s" $a [eval \ - get/[lindex $attr($a) 0] [lrange $attr($a) 1 end] [list $a]]] - set acted 1 - } default { - if {[catch { elite-unpackcmdr cmdr [read-file $a] } err]} { - puts stderr "$argv0: couldn't read `$a': $err" - exit 1 + set n 0 + foreach aa $attrs { + if {[string match $a $aa]} { + incr n + puts [format "%-20s %s" $aa [eval \ + get/[lindex $attr($aa) 0] \ + [lrange $attr($aa) 1 end] [list $aa]]] + } + } + if {$n} { + set acted 1 + } else { + if {[catch { elite-unpackcmdr cmdr [read-file $a] } err]} { + puts stderr "$argv0: couldn't read `$a': $err" + exit 1 + } } } } -- 2.11.0