または、tcllibのcmdlineパッケージのようなものを使用することもできます。これにより、バイナリフラグと名前/値引数のデフォルトを設定し、それらに説明を付けて、フォーマットされたヘルプメッセージを表示できるようにすることができます。たとえば、入力ファイル名と、オプションで出力ファイル名と出力を圧縮するためのバイナリオプションを必要とするプログラムがある場合は、次のようなものを使用できます。
package require cmdline
set sUsage "Here you put a description of what your program does"
set sOptions {
{inputfile.arg "" "Input file name - this is required"}
{outputfile.arg "out.txt" "Output file name, if not given, out.txt will be used"}
{compressoutput "0" "Binary flag to indicate whether the output file will be compressed"}
}
array set options [::cmdline::getoptions argv $sOptions $sUsage]
if {$options(inputfile) == ""} {puts "[::cmdline::usage $sOptions $sUsage]";exit}
.argサフィックスは、これが名前と値のペアの引数であることを示します。リストされていない場合は、バイナリフラグであると見なされます。