reports/Builder__ReportRunner.st
changeset 232 3c3f5f58ddeb
parent 230 9e0098682d8c
child 238 c5047b0ed211
--- a/reports/Builder__ReportRunner.st	Tue May 27 18:05:54 2014 +0200
+++ b/reports/Builder__ReportRunner.st	Tue May 27 18:06:01 2014 +0200
@@ -275,18 +275,19 @@
            nextPutAll: (OperatingSystem isMSWINDOWSlike ifTrue:['bat'] ifFalse:['sh']);
            nextPutAll: ' [-D <dir>] -r <report> [-p <package1> [-p <package2> [...]]]'; cr.
 
+    Stderr nextPutLine:'Common options:'; cr.
+
     Stderr nextPutLine:'  --help .................. output this message'.
-    Stderr nextPutLine:'  --verbose ............... verbose startup'.
-    Stderr nextPutLine:'  --noBanner .............. no splash screen'.
-    Stderr nextPutLine:'  --newAppInstance ........ start as its own application process (do not reuse'.
-    Stderr nextPutLine:'                            a running instance)'.
-    self allowScriptingOption ifTrue:[
-        Stderr nextPutLine:'  --scripting portNr ...enable scripting via port (or stdin/stdOut if 0)'.
-    ].
+"/    Stderr nextPutLine:'  --verbose ............... verbose startup'.
+"/    Stderr nextPutLine:'  --noBanner .............. no splash screen'.
+"/    Stderr nextPutLine:'  --newAppInstance ........ start as its own application process (do not reuse'.
+"/    Stderr nextPutLine:'                            a running instance)'.
+"/    self allowScriptingOption ifTrue:[
+"/        Stderr nextPutLine:'  --scripting portNr ...enable scripting via port (or stdin/stdOut if 0)'.
+"/    ].
     self allowDebugOption ifTrue:[
         Stderr nextPutLine:'  --debug ................. enable Debugger'.
     ].
-
     "/                 '  ......................... '
     Stderr nextPutLine:'  -D <dir>'.
     Stderr nextPutLine:'  --output-directory=<dir>  directory where report files will go'.
@@ -307,15 +308,73 @@
     Stderr nextPutLine:'  -p <package>'.
     Stderr nextPutLine:'  --package=<package> ..... package to run report on'.
     Stderr nextPutLine:'                            May be specified multiple times.'.
-    debugging ifTrue:[
+
+    Report available do:[:cls|
+        self usageForReportClass: cls.
+    ].
+
+
+    debugging ifFalse:[
         Smalltalk exit:1.
-    ]
+    ].
     "
     self usage
     "
 
     "Created: / 13-01-2012 / 11:48:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 22-01-2014 / 09:58:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-05-2014 / 17:02:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+usageForReportClass: class
+    | options |
+
+    "/ '.........................' size  25
+    options := CmdLineOption optionsFor: class new.
+    options := options reject:[:option | 'pF' includes: option short  ].
+    options notEmptyOrNil ifTrue:[
+        Stderr cr.
+        Stderr nextPutAll: class name; nextPutLine:' options:'; cr.
+        options do:[:option |                
+            | optlen |  
+
+            Stderr nextPutAll: '  '.
+            option short notNil ifTrue:[ 
+                Stderr nextPut: $-; nextPut: option short; space.
+                optlen := 2.
+                option hasParam ifTrue:[ 
+                    | paramName |
+
+                    paramName := 'val'.
+                    Stderr nextPut:$<; nextPutAll: paramName; nextPut:$>; space.
+                    optlen := optlen + 3 + paramName size.
+                ].
+            ].
+            option long notNil ifTrue:[ 
+                 option short notNil ifTrue:[ 
+                    Stderr cr.
+                ].
+                Stderr nextPutAll: '  --'.
+                Stderr nextPutAll: option long.
+                optlen := option long size + 2.
+                option hasParam ifTrue:[ 
+                    | paramName |
+
+                    paramName := 'val'.
+                    Stderr nextPut:$=; nextPut:$<; nextPutAll: paramName; nextPut:$>.
+                    optlen := optlen + 3 + paramName size.
+                ].
+                Stderr space.
+            ].
+            Stderr next: (26 - 1"space" -2"--" - optlen) put: $..    
+            Stderr space.
+            option description notNil ifTrue:[
+                Stderr nextPutAll: option description
+            ].
+            Stderr cr.
+        ]
+    ]
+
+    "Created: / 27-05-2014 / 16:42:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !ReportRunner class methodsFor:'startup-to be redefined'!
@@ -326,6 +385,9 @@
     | argv |
 
     argv := argv0 asOrderedCollection.
+    argv isEmpty ifTrue:[ 
+        self usage.
+    ].
     argv remove: '--abortOnSEGV' ifAbsent:[nil].
     parser := CmdLineParser new.
     CmdLineOptionError autoload.
@@ -371,7 +433,7 @@
         ]
     ]
 
-    "Modified: / 12-02-2014 / 15:13:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 27-05-2014 / 17:05:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !ReportRunner class methodsFor:'documentation'!