-? or -h command option support in Tcl-core
From: Andreas Sievers (andreas.sievers_at_t-online.de)
Date: 03/28/04
- Previous message: Joe English: "ANNOUNCE: Tile Widget Set, version 0.3"
- Next in thread: lvirden_at_yahoo.com: "Re: -? or -h command option support in Tcl-core"
- Reply: lvirden_at_yahoo.com: "Re: -? or -h command option support in Tcl-core"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 28 Mar 2004 00:20:50 +0100
Currently, there´s no official way to get straight forward information about
a command, like options or subcommands dynamically.
On the other hand, you will get a lot of information via the build in
error-mechanism, but this depends heavily on the context.
ie. a single puts will return "wrong # args: should be "puts ?-nonewline?
?channelId? string".
If you enter a Tk-command like text, you will only get back "wrong # args:
should be "text pathName ?options?", which tells nothing about available
options and subcommands.
You have the chance to try "text -?" to cause another error which will
result in: "bad window path name "-?", but that will not really help you, if
you are a novice.
If you are more experienced, you can try "text .t", which will instanciate a
text-widget and then query for options:
.t configure
which will result in a list of possible options (but messing you caused by
the format with additional info). And then you can try
.t -? for all subcommands
To be able to query, you MUST create a widget instance and then (if not
needed any more) destroy it again.
But there´s no way to query allowed options and/or subcommands directly and
context-independent, ie. text -?
I thought about to write a package introducing a help command, which will
return informations about a command (ie. help <command>). But, unless you
don´t want to write a hard-coded list of commands and their options, this
has to use the available error-information, like I did it for the current
ASED version, which is quite arkward. After all, I´d prefer a command option
supported by the tcl-core to query those informations or a help command,
implemented in the tcl-core, which would not only help to develop
online-assistance for Editors/IDEs, but also is a good habbit on regular
unix-commands and could be a great help, if you work interactively in a
tcl-shell.
I wonder, if it would be possible to combine all informations available for
a command by the error-information to realize a context-independent query-co
mmand.
I know that this might cause incompatibilities, since some commands
currently accept -? as a valid option (ie puts). Maybe a help command or an
expansion of the info command (like info commands command) might be an
alternative, if it would return the needed information.
I´m really interested in hearing what other people think about that.
- Previous message: Joe English: "ANNOUNCE: Tile Widget Set, version 0.3"
- Next in thread: lvirden_at_yahoo.com: "Re: -? or -h command option support in Tcl-core"
- Reply: lvirden_at_yahoo.com: "Re: -? or -h command option support in Tcl-core"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|