#196589 - 2009-11-05 05:16 PM
Re: Method to "gobble" the command line
[Re: Lonkero]
|
Glenn Barnas
KiX Supporter
   
Registered: 2003-01-28
Posts: 4400
Loc: New Jersey
|
I want to bump this up again, since it's really beginning to affect my ability to use Kix in complex applications.
The fact that Kix32 recognizes both "/" and "-" as argument lead-ins prevents the use of any argument that begins with reserved parameters.
For example, if I choose to use "-Dump" as a script argument to dump some data, Kix32 interprets it as "/D", resulting in the script running in debug mode and not performing the dump. Clearly "-Dump" and "/D" are different, so there's no real reason for Kix to "get in the way". I'm using "+Dump" and "+Hotfix" parameters in some scripts, but the "+" is "unnatural". Using "--dump" works, but is unnatural for users not familiar with Unix/Posix command lines. I can't tell you how many times I've gotten calls from users that ran "script -hotfix:package6" and got a strange (and unrelated to their task) help message instead of having the hotfix package applied.
There's also the issue of arguments being interpreted as secondary script names. This causes problems unless you remember to terminate / exit your script with Quit to prevent further script execution. The general concensus was that this is a rarely used feature, although we don't necessarily want a change that will break functionality.
I'd really like to see the following changes to Kix for the next release, which would significantly improve handling of command-line arguments. Nearly 80% of my scripts REQUIRE arguments, and nearly all accept arguments.- Restrict Kix to strict native interpretation of command line parameters, so the alternate can be used by the script itself. For example, any of the following:
- Kix only responds to "/" parameters - "/d" and not "-d" for debug
- Kix qualifies the parameters it responds to - "/d" for debug, but "/demand" is ignored.
- Since Kix args are used less often than script args, how about requiring them to be "spelled-out", as in /debug, /tokenize, /flushcache, /unlock, /?, /help, and /rpcsearch?
- Require Kix to recognize its arguments with "--" is another (my favorite) approach, which allows all "/" or "-" arguments to pass to the scripts unmolested.
- Implementation of a method to clear the command line, so that further processing of arguments as script names is not done. This can be a ClearCommandLine() function, or an optional parameter added to GetCommandLine(). I'd prefer the latter, so that if I'm using GetCommandLine() I can clear it at the same time. Using
$aCmdLine = GetCommandLine(1,1) would return the command line as an array and flush it, causing further calls to GetCommandLine() to return nothing, and preventing Kix from parsing script args as script names. I'm thinking that there should be some kind of middle ground that allows simple and uncomplicated use of command-line arguments and parameters.
Thanks!
Glenn
_________________________
Actually I am a Rocket Scientist!
|
Top
|
|
|
|
Moderator: ShaneEP, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Ruud van Velsen, Mart
|
0 registered
and 676 anonymous users online.
|
|
|