0024802: "help" command shouldn't apply implicit rules in definition process of what...
authorapl <apl@opencascade.com>
Mon, 6 Oct 2014 14:55:14 +0000 (18:55 +0400)
committerbugmaster <bugmaster@opencascade.com>
Fri, 10 Oct 2014 12:22:45 +0000 (16:22 +0400)
 -When in "help <command>" <command> was exactly found in existing draw commands, then helpstring for this <command> is displayed,
  else "help" fails and error message is displayed
 -When "*word" or "word*" or any other combination is given in args, then help command performs typical wildcard search.

src/DrawResources/StandardCommands.tcl

index 12ff657..a56b9d3 100644 (file)
@@ -39,44 +39,52 @@ proc help {{command ""} {helpstring ""} {group "Procedures"}} {
 
     if {$command == ""} {
 
-       # help general
-       foreach h [lsort [array names Draw_Groups]] {
-           puts ""
-           puts ""
-           puts $h
-           set i 0
-           foreach f [lsort $Draw_Groups($h)] {
-               if {$i == 0} {
-                   puts ""
-                   puts -nonewline "  "
-               }
-               puts -nonewline $f
-               for {set j [string length $f]} {$j < 15} {incr j} {
-                   puts -nonewline " "
-               }
-               incr i
-               if {$i == 4} {set i 0}
-           }
-           puts ""
-       }
+    # help general
+    foreach h [lsort [array names Draw_Groups]] {
+        puts ""
+        puts ""
+        puts $h
+        set i 0
+        foreach f [lsort $Draw_Groups($h)] {
+        if {$i == 0} {
+            puts ""
+            puts -nonewline "  "
+        }
+        puts -nonewline $f
+        for {set j [string length $f]} {$j < 15} {incr j} {
+            puts -nonewline " "
+        }
+        incr i
+        if {$i == 4} {set i 0}
+        }
+        puts ""
+    }
     } elseif {$helpstring == ""} {
 
-       # help fonction
-       append command "*"
-       foreach f [lsort [array names Draw_Helps]] {
-           if {[string match $command $f]} {
-               puts -nonewline $f
-               for {set j [string length $f]} {$j < 15} {incr j} {
-                   puts -nonewline " "
-               }
-               puts " : $Draw_Helps($f)"
-           }
-       }
+    # help function
+    set isfound 0
+    foreach f [lsort [array names Draw_Helps]] {
+        if {[string match $command $f]} {
+        puts -nonewline $f
+        for {set j [string length $f]} {$j < 15} {incr j} {
+            puts -nonewline " "
+        }
+        puts " : $Draw_Helps($f)"
+        set isfound 1
+        }
+    }
+    if {!$isfound} {
+        if {[string first * $command] != -1} {
+            puts "No matching commands found!"
+        } else {
+            puts "No help found for '$command'! Please try 'help $command*' to find matching commands."
+        }
+    }
     } else {
 
-       # set help
-       lappend Draw_Groups($group) $command
-       set Draw_Helps($command) $helpstring
+    # set help
+    lappend Draw_Groups($group) $command
+    set Draw_Helps($command) $helpstring
     }
     
     flush stdout