Cmdargs is a Tcl extension that provides a command-line interface to any user-created proc.

The extension is easy to use. You can install it by copying the appropriate cmdargs1.0 directory (from the unix or win-msys directory under tcl8 or tcl9) to the package directory where Tcl is installed (usually tcl__/lib).

Add "package require cmdargs" in your Tcl source file. Then call cmdargs::chkArgs in your proc as follows:

    package require cmdargs
    proc Test {args} {
        cmdargs::chkArgs $args -dstr {mydog "Fluffy" mycat "PurrBall"} -dnum {dogfood 53 catfood 21}
        # use values 

    The syntax is quite simple: first argument is the list of command line parameters, 
    this is typically captured by the args variable.
    The rest of the arguments describe the options and default values.
    Option name becomes variable name in proc, and
    variables are set to the default values:
      $mydog => Fluffy, $mycat => PurrBall, $dogfood => 53, $catfood => 21

    Call the proc using command line input: <-option value ...>. The created variables 
    are set to the values entered on the command line:
      % Test -catfood 128 -mycat FurBall
      % puts "Yikes! $mycat's food costs \$$catfood/month now!" 
        Yikes! FurBall's food costs $128/month now!

    Options NOT used on command line retain their initial defaults
      % puts "But $mydog still eats kibble worth \$$dogfood/month."     
        But Fluffy still eats kibble worth $53/month.

That covers a good part of the basics. For more information consult the Documentation.

Source and binaries are available for Download.