After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 707597 - Pass --help option on to script, if given
Pass --help option on to script, if given
Status: RESOLVED DUPLICATE of bug 708831
Product: gjs
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal minor
: ---
Assigned To: gjs-maint
gjs-maint
Depends on:
Blocks:
 
 
Reported: 2013-09-05 22:49 UTC by Philip Chimento
Modified: 2014-03-27 03:05 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Philip Chimento 2013-09-05 22:49:20 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"
Comment 1 sébastien lafargue 2013-09-08 19:03:30 UTC
you could always use -- to force passing options to your script :

gjs script.js -- --help
Comment 2 Cosimo Cecchi 2014-03-26 22:51:36 UTC
Philip, is that solution acceptable? If so, I think we should close this.
Comment 3 Philip Chimento 2014-03-27 02:48:10 UTC
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.
Comment 4 Philip Chimento 2014-03-27 03:05:44 UTC
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 ***