Version 5 of info commands

Updated 2004-03-14 23:08:19

info commands ?pattern?

If pattern isn't specified, returns a list of names of all the Tcl commands in the current namespace, including both the built-in commands written in C and the command procedures defined using the proc command. If pattern is specified, only those names matching pattern are returned. Matching is determined using the same rules as for string match. Pattern can be a qualified name like Foo::print*. That is, it may specify a particular namespace using a sequence of namespace names separated by ::s, and may have pattern matching special characters at the end to specify a set of commands in that namespace. If pattern is a qualified name, the resulting list of command names has each one qualified with the name of the specified namespace.


MGS [2004/03/14] - Don't forget that info commands will not tell you the names of all possible commands - some commands are auto-loaded using the unknown and auto_load mechanism. To get a list of all possible commands, I use something like this:

 proc commands {{pattern *}} {
   return [lsort -unique [concat \
     [info commands $pattern] \
     [array names ::auto_index $pattern] \
   ]]
 }

 # example
 set tk_commands [commands ::tk::*]

Note: this will extract commands from the auto_index array which match the specified pattern and commands from all descendant namespaces (this may not be what you want or expect). See array names for more info.


See also:


Category Command - Tcl syntax help