RosettaCodeData/Task/Named-parameters/Tcl/named-parameters-2.tcl
Ingy döt Net b83f433714 tasks a-s
2013-04-10 23:57:08 -07:00

18 lines
717 B
Tcl
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package require opt
tcl::OptProc example {
{-foo -int 0 "The number of foos"}
{-bar -float 1.0 "How much bar-ness"}
{-grill -any "hamburger" "What to cook on the grill"}
} {
return "foo is $foo, bar is $bar, and grill is $grill"
}
example -grill "lamb kebab" -bar 3.14
# => foo is 0, bar is 3.14, and grill is lamb kebab
example -help
# Usage information:
# Var/FlagName Type Value Help
# ------------ ---- ----- ----
# ( -help gives this help )
# -foo int (0) The number of foos
# -bar float (1.0) How much bar-ness
# -grill any (hamburger) What to cook on the grill