Hi all,

I found it useful to be able to pass -V/-v/--verbose to all of the
tools. The patch is implemented it in the brute force way. I wonder if a
patch to create a base for the tools and common option handling would be
appreciated?

regards
  holger
>From 03a42898a1c19a79b5e78baf074c349bd8ed248a Mon Sep 17 00:00:00 2001
From: Holger Hans Peter Freyther <[email protected]>
Date: Mon, 3 May 2010 12:18:45 +0800
Subject: [PATCH] Add --verbose to various tools

2010-05-03  Holger Hans Peter Freyther <[email protected]>

	* gst-tools.c: Add -v|-V|--verbose to all tools.
	* scripts/Package.st: Handle the verbose option.
	* scripts/GenDoc.st: Likewise.
	* scripts/Profile.st: Likewise.
	* scripts/Remote.st: Likewise.
---
 ChangeLog          |    8 ++++++++
 gst-tool.c         |   14 +++++++-------
 scripts/GenDoc.st  |    8 +++++++-
 scripts/Package.st |    9 +++++++--
 scripts/Profile.st |    8 +++++++-
 scripts/Remote.st  |    8 +++++++-
 6 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d2701a0..28405f2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-05-03  Holger Hans Peter Freyther <[email protected]>
+
+	* gst-tools.c: Add -v|-V|--verbose to all tools.
+	* scripts/Package.st: Handle the verbose option.
+	* scripts/GenDoc.st: Likewise.
+	* scripts/Profile.st: Likewise.
+	* scripts/Remote.st: Likewise.
+
 2010-04-24  Holger Hans Peter Freyther <[email protected]>
 
 	* kernel/PkgLoader.st: Print the file name of the package that will
diff --git a/gst-tool.c b/gst-tool.c
index 85d3e37..bbdfa3c 100644
--- a/gst-tool.c
+++ b/gst-tool.c
@@ -7,7 +7,7 @@
 
 /***********************************************************************
  *
- * Copyright 2007, 2008, 2009 Free Software Foundation, Inc.
+ * Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
  * Written by Paolo Bonzini.
  *
  * This file is part of GNU Smalltalk.
@@ -106,7 +106,7 @@ const struct tool tools[] = {
   },
   {
     "gst-package", "scripts/Package.st",
-    "-h|--help --version --load --no-load --no-install --uninstall --dist \
+    "-h|--help --version -v|-V|--verbose --load --no-load --no-install --uninstall --dist \
         --prepare --test -t|--target-directory: --list-files: --list-packages \
         --srcdir: --distdir|--destdir: --copy --all-files --vpath -n|--dry-run \
         -I|--image-file: --kernel-directory: --update|--download ",
@@ -120,31 +120,31 @@ const struct tool tools[] = {
   },
   {
     "gst-browser", "scripts/Load.st",
-    "-I|--image-file: --kernel-directory:",
+    "-I|--image-file: --kernel-directory: -v|-V|--verbose",
     "--dry-run\0--start\0Browser\0", false
   },
   {
     "gst-blox", "scripts/Load.st",
-    "-I|--image-file: --kernel-directory:",
+    "-I|--image-file: --kernel-directory: -v|-V|--verbose",
     "--dry-run\0--start\0BLOXBrowser\0", false
   },
   {
     "gst-doc", "scripts/GenDoc.st",
     "-h|--help --version -p|--package: -f|--file: -I|--image-file: \
-        -n|--namespace: -o|--output: --kernel-directory: -F|--output-format:",
+        -n|--namespace: -o|--output: --kernel-directory: -F|--output-format: -v|-V|--verbose",
     NULL, true
   },
   {
     "gst-remote", "scripts/Remote.st",
     "-h|--help --version --daemon --server -p|--port: -f|--file: -e|--eval: \
  	-l|--login: --package: --start: --stop: --pid --kill --snapshot:: \
-	-I|--image-file: --kernel-directory:",
+	-I|--image-file: --kernel-directory: -v|-V|--verbose",
     NULL, true
   },
   {
     "gst-profile", "scripts/Profile.st",
     "-f|--file: -e|--eval: -o|--output: -h|--help --version \
-	--no-separate-blocks",
+	--no-separate-blocks -v|-V|--verbose",
     NULL, true
   },
 
diff --git a/scripts/GenDoc.st b/scripts/GenDoc.st
index b8d0653..c7f2d0e 100644
--- a/scripts/GenDoc.st
+++ b/scripts/GenDoc.st
@@ -49,6 +49,7 @@ Options:
        --kernel-dir=PATH  use the specified kernel directory
     -F --output-format=KIND   use the given publisher (HTML or default=Texinfo)
     -h --help             show this message
+    -v --verbose          print extra information while processing
        --version          print version information and exit
 
 '.
@@ -60,7 +61,8 @@ Options:
     "Parse the command-line arguments."
     Smalltalk
         arguments: '-h|--help --version -p|--package: -f|--file: -n|--namespace:
-                    -I|--image-file: -o|--output: --kernel-directory: -F|--output-format:'
+                    -I|--image-file: -o|--output: --kernel-directory: -F|--output-format:
+		    -v|-V|--verbose'
         do: [ :opt :arg |
 
         opt = 'help' ifTrue: [
@@ -113,6 +115,10 @@ Options:
                         ifTrue: [ publisher:= STInST.TexinfoDocPublisher ]
                         ifFalse: [ self error: 'unknown --output-format arg' ] ] ].
 
+	opt = 'verbose' ifTrue: [
+	    OutputVerbosity := 1.
+	    FileStream verbose: true ].
+
         opt isNil ifTrue: [ classPatterns add: arg ] ]
 
         ifError: [
diff --git a/scripts/Package.st b/scripts/Package.st
index 6e80f7e..34ee3f2 100644
--- a/scripts/Package.st
+++ b/scripts/Package.st
@@ -482,7 +482,7 @@ Object subclass: Command [
 
     isValidOption: aString [
 	^#('srcdir' 'target-directory' 'destdir' 'image-file'
-	   'dry-run' 'kernel-directory') includes: aString
+	   'dry-run' 'kernel-directory' 'verbose') includes: aString
     ]
 
     isOption: aString [ ^options includesKey: aString ]
@@ -1100,6 +1100,7 @@ Common suboptions:
         --target-directory DIR  install the files in DIR (unused for --dist)
     -I, --image-file=FILE       load into the specified image
         --kernel-dir=PATH       use the specified kernel directory
+    -v, --verbose               print extra information while processing
 
 --install suboptions:
 	--test                  run unit tests after merging
@@ -1147,7 +1148,7 @@ The default target directory is ', Directory image name, '
                 --dist -t|--target-directory: --list-files: --list-packages
                 --prepare --srcdir: --distdir|--destdir: -n|--dry-run
 		--all-files --vpath --copy -I|--image-file: --kernel-directory:
-		--update|--download --version'
+		--update|--download --version -v|-V|--verbose'
 
             do: [ :opt :arg || modeClass |
 	        opt = 'help' ifTrue: [
@@ -1157,6 +1158,10 @@ The default target directory is ', Directory image name, '
 		    ('gst-package - %1' % {Smalltalk version}) displayNl.
 		    ObjectMemory quit: 0 ].
 
+		opt = 'verbose' ifTrue: [
+		    OutputVerbosity := 1.
+		    FileStream verbose: true ].
+
 		modeClass := self class classForMode: opt.
 		modeClass notNil ifTrue: [ self mode: modeClass ].
 
diff --git a/scripts/Profile.st b/scripts/Profile.st
index e804379..7abfee8 100644
--- a/scripts/Profile.st
+++ b/scripts/Profile.st
@@ -49,6 +49,7 @@ Options:
     -e --eval=CODE            evaluate CODE
     -o --output=FILE          output file for callgrind_annotate
     -h --help                 show this message
+    -v --verbose              print extra information while processing
        --no-separate-blocks   do not track blocks separately
        --version              print version information and exit
 
@@ -61,7 +62,7 @@ or --eval options.
 "Parse the command-line arguments."
 [Smalltalk
     arguments: '-f|--file: -e|--eval: -o|--output: -h|--help --version
-		--no-separate-blocks'
+		--no-separate-blocks -v|-V|--verbose'
     do: [ :opt :arg |
 
     opt = 'help' ifTrue: [
@@ -85,6 +86,11 @@ or --eval options.
     opt = 'eval' ifTrue: [
 	commands add: arg ].
 
+    opt = 'verbose' ifTrue: [
+	OutputVerbosity := 1.
+	FileStream verbose: true
+    ].
+
     opt isNil ifTrue: [
 	last isNil
 	    ifTrue: [ last := arg ]
diff --git a/scripts/Remote.st b/scripts/Remote.st
index dc6e95b..1e6c61c 100644
--- a/scripts/Remote.st
+++ b/scripts/Remote.st
@@ -94,6 +94,7 @@ Options:
        --stop=PACKAGE[:DATA]  load package and stop it (defined in package.xml)
        --pid                  print daemon pid
     -h --help                 show this message
+    -v --verbose              print extra information while processing
        --version              print version information and exit
 
 If a remote login name is given, gst-remote will use the SSH environment
@@ -106,7 +107,8 @@ available in the PATH of the remote machine.
 [Smalltalk
     arguments: '-h|--help --version --daemon --server -p|--port: -f|--file:
 		-e|--eval: --pid --kill --snapshot:: --start: --stop:
-		-l|--login: --package: -I|--image: --kernel-directory:'
+		-l|--login: --package: -I|--image: --kernel-directory:
+		-v|-V|--verbose'
     do: [ :opt :arg |
 
     opt = 'help' ifTrue: [
@@ -173,6 +175,10 @@ available in the PATH of the remote machine.
 	    ifFalse: [ commands add: 'ObjectMemory snapshot: ',
 			     (Directory working / arg) name storeString ] ].
 
+    opt = 'verbose' ifTrue: [
+	OutputVerbosity := 1.
+	FileStream verbose: true ].
+
     opt isNil ifTrue: [
 	host isNil ifFalse: [ self error: 'multiple hosts are invalid' ].
 	(arg includes: $@)
-- 
1.7.0.1

_______________________________________________
help-smalltalk mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-smalltalk

Reply via email to