GNOME Bugzilla – Bug 707597
Pass --help option on to script, if given
Last modified: 2014-03-27 03:05:44 UTC
I propose that invoking gjs with --help should only print gjs's help if there is no script given on the command line. Otherwise, it is impossible for a script to react to a --help command line option: script.js: ---------- if(ARGV.indexOf('--help') != -1) print('You asked for help'); else print("You didn't ask for help"); terminal: --------- $ gjs script.js You didn't ask for help $ gjs script.js --help Usage: gjs [OPTION...] Help Options: -h, --help Show help options Application Options: -c, --command=COMMAND Program passed in as a string -I, --include-path=DIR Add the directory DIR to the list of directories to search for js files. --js-version=JSVERSION JavaScript version (e.g. "default", "1.8"
you could always use -- to force passing options to your script : gjs script.js -- --help
Philip, is that solution acceptable? If so, I think we should close this.
It's not a big deal, but just slightly annoying that you can't make GJS scripts behave like other scripts - if you want to ship a GJS script as a utility or something, then an unsuspecting user executing "my-awesome-utility --help" like they would with any other utility will get a totally unhelpful help message. Essentially you're leaking the implementation detail of your script being written in GJS. I thought about specifying the -- as part of the #! line, like "#!/usr/bin/gjs --" but I realized there was no way to get the -- to be passed _after_ the file being executed. I guess you have to write a wrapper shell script that tacks its arguments on after "/usr/bin/gjs my-real-script.js --". I'm a bit more at home in the GJS codebase than I was when I filed this bug so I can probably put together a patch quickly if you agree that the above is a problem.
Actually, this has already been fixed in master. Closing this as a duplicate of https://bugzilla.gnome.org/show_bug.cgi?id=708831 *** This bug has been marked as a duplicate of bug 708831 ***