Author: sparky
Date: Fri Jan 19 21:47:29 2007
New Revision: 8183

Modified:
   vfmg/trunk/vfmg
Log:
- display line no longer than 80 chars when printing available outputs


Modified: vfmg/trunk/vfmg
==============================================================================
--- vfmg/trunk/vfmg     (original)
+++ vfmg/trunk/vfmg     Fri Jan 19 21:47:29 2007
@@ -46,14 +46,27 @@
 our $o_output;
 $defopt{xterm}="$ENV{'VFMG_TERM'}" if $ENV{'VFMG_TERM'};
 
-sub wms() {
+sub wms($) {
        my @wms;
        foreach (grep -d, map {"$_/VFMG"} @INC) {
                opendir DIR, $_;
                push @wms, map /^(.*)_out\.pm$/, readdir DIR;
                closedir DIR;
        }
-       return join ", ", sort @wms;
+       my $last = "";
+       @wms = grep { my $r = ($_ ne $last); $last = $_; $r } sort @wms;
+       my $line = (shift @_) . " { " . (shift @wms);
+       my $done = "";
+       foreach my $wm (@wms) {
+               if( (length $line) + (length $wm) + 2 >= 80 ) {
+                       $done .= $line . ",\n";
+                       $line = "    " . $wm;
+               } else {
+                       $line .= ", " . $wm;
+               }
+       }
+       $done .= $line . " }\n";
+       return $done;
 }
 # }}}
 
@@ -104,13 +117,12 @@
        ); # }}}
 
 if($o_help) { # {{{
-       my $wms = wms();
+       print wms("Usage: $0 [options]");
        print <<EOF;
-Usage: $0 [options] {$wms}
 
 Options:
-    -h, --help   - print this help and exit
-    -V, --version        - print version information and exit
+    -h, --help    - print this help and exit
+    -V, --version - print version information and exit
 
   Diagnostics:
     -t, --tags    - echo omitted tags to stderr
@@ -163,7 +175,7 @@
        exit;
 }
 
-die "Missing argument {".wms()."}\n" unless exists $ARGV[0];
+die wms("Missing argument") unless exists $ARGV[0];
 
 # search dirs {{{
 our @xdg_data_dirs = grep -d,
@@ -192,7 +204,7 @@
 $o_output = $ARGV[0];
 require "VFMG/${o_output}_out.pm"; # for testing
 eval { require "VFMG/${o_output}_out.pm" }
-       or die "Unrecognized argument: $o_output\n";
+       or die "Unrecognized argument: $o_output\n" . wms("Available outputs");
 
 # vfmgrc {{{
 my @rcFiles = ("/etc/vfmgrc", "$ENV{'HOME'}/.vfmgrc");
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to