On Tuesday, January 10, 2023 at 2:41:46 PM UTC-8, Schelte wrote:
> > I don't want to change the "-help" option as I want the user to have a standard way of asking and it's used 50 other places.
> Run your script with tclsh instead of wish. Process $argv, or copy it to
> another variable. Then clear argv and do a [package require Tk].
>
> Schelte.
Will work of course, but personally I still think it's easier to just use '--' if the OP wants to stay with wish...
Example "args.tcl" :
foreach arg $argv { puts "my arg = $arg" }
%> wish args.tcl -help
Application initialization failed: Command-specific options:
-colormap: Colormap for main window
-display: Display to use
-geometry: Initial geometry for window
-name: Name to use for application
-sync: Use synchronous mode for display server
-visual: Visual for main window
-use: Id of window in which to embed application
--: Pass all remaining arguments through to script
my arg = -help
%> wish args.tcl -- -help
my arg = -help
First invocation causes an error because '-help' is not a wish argument (so no Tk window is displayed) but runs the script (print argv contents)
Second invocation opens a Tk window, passes -help to argv, and runs the script (print argv contents)
Shaun