Closed Bug 1175968 Opened 10 years ago Closed 10 years ago

Can't pass --help to firefox with ./mach run because ./mach itself reads the --help argument

Categories

(Firefox Build System :: Mach Core, enhancement)

enhancement
Not set
normal

Tracking

(firefox41 affected, firefox42 fixed)

RESOLVED FIXED
mozilla42
Tracking Status
firefox41 --- affected
firefox42 --- fixed

People

(Reporter: Gijs, Assigned: tr.supradeep, Mentored)

References

Details

(Whiteboard: [lang=python])

Attachments

(1 file, 1 obsolete file)

gps suggested "./mach run -- --help" but that didn't work either.
https://hg.mozilla.org/mozilla-central/file/2694ff2ace6a/python/mach/mach/dispatcher.py#l103 is the problematic code. We should ignore arguments after '--' when scanning for the special help flags. This would be a good first bug.
Mentor: gps
Whiteboard: [lang=python]
I think --help should just be treated like other flags. As in, added to the ArgumentParser instance for the command.
Hi. I would like to work on this bug, and it may be my first. How should I go about reproducing this bug?
$ mach build $ mach run -- --help That second command should display Firefox's help message, not mach's. Also, while I agree with comment #2, integrating --help handling into the ArgumentParser is a bit complicated. Let's defer that to another time and go with a hack to the code linked to in comment #1.
I was just thinking in the lines of comment #1 by gps, as there is line which calls for command_help if '-h' or '--help' is found. We could skip it as you(gps) said by skipping all flags after '-- ' (I think that whitespace would matter), but how do we then forward the rest of the flags to Firefox functions? Or for now are you saying just ignore them? (I am new here, but used to Python scripting and coding, would need a lot of feedback) And also, how do build only mach?
(In reply to tr.supradeep from comment #5) > We could skip it as you(gps) said by skipping all flags after '-- ' (I think > that whitespace would matter), but how do we then forward the rest of the > flags to Firefox functions? This is already implemented and not something you need to be concerned with. > And also, how do build only mach? mach doesn't have a build system. It's just a bunch of Python code that is parsed at run-time. Test changes by changing the source code then running `mach`.
Thank you for the clarifications gps. May I work on this bug? As wasif_hyder hasn't replied yet. This is my first with Mozilla Firefox. So I think can't we just remove https://hg.mozilla.org/mozilla-central/file/2694ff2ace6a/python/mach/mach/dispatcher.py#l103 elif conditional statement? That is what is finding '-h' or '--help' in the arguments passed and returning the command_help. Am I right?
Yes, you can take it. Removing the elif would break `mach build --help`. You need to modify the code to only honor -h/--help if they come before an '--' argument. The following should display help: $ mach help run $ mach run --help $ mach run -h The following should *not* display help: $ mach run -- -h $ mach run -- --help
Assignee: nobody → tr.supradeep
Status: NEW → ASSIGNED
Thank you. I wanted a suggestion for the best editor to use for Python editing. I am facing many problems while using Notepad++ (indentations problems of 'spaces' vs 'tabs'). I tried both 4 spaces and single tab but can't shake off the errors. I used to use PyCharms as preferred IDE. Also which would be better code? 1. elif '--' == args[0] and restof statements. or 2. elif args.index('--') < args.index('-h') or args.index('--') < args.index('--help') and rest. or 3. Truncate args from '--' onwards such that others command after it are removed and not honored. Sorry for asking so many questions. I am quite new and will take some time.
I'd look at https://stackoverflow.com/questions/81584/what-ide-to-use-for-python. I use vim. But only because I'm old school. I should be using one of the newer ones.
Attached patch bug-1175968-fix.patch (obsolete) — Splinter Review
I have added the requested patch. Your feedback will be gladly accepted.
Attachment #8632408 - Flags: review+
Attachment #8632408 - Attachment is obsolete: true
Attached patch new_patch.patchSplinter Review
Previous attachment were wrong commits. This attachment has it in the right order. Sorry that I had issues with Mercurial. Using mq seems slightly complicated, and I read your blog post on mq being obsolete. Why is mq still used?
Attachment #8632411 - Flags: review+
Attachment #8632411 - Flags: review+ → review?(gps)
Comment on attachment 8632411 [details] [diff] [review] new_patch.patch Review of attachment 8632411 [details] [diff] [review]: ----------------------------------------------------------------- Good work. I'll land this for you.
Attachment #8632411 - Flags: review?(gps) → review+
url: https://hg.mozilla.org/integration/fx-team/rev/a3a4614025057f20765f16fc6b516b973bec6ef9 changeset: a3a4614025057f20765f16fc6b516b973bec6ef9 user: Supradeep T R <tr.supradeep@gmail.com> date: Mon Jul 13 16:58:54 2015 -0700 description: Bug 1175968 - Honor '-h' or '--help' only if it appears before '--'; r=gps
This has landed. Assuming it doesn't break things (it shouldn't), there is nothing more that needs to be done. Thanks again for contributing this fix!
Status: ASSIGNED → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla42
Thank you very much for guiding and mentoring GPS, it was a delightful learning experience.
Depends on: 1184780
Product: Core → Firefox Build System
Blocks: 1761834
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: