#7843 closed feature request (fixed)

GHC should be able to list all possible command line options

Reported by: jstolarek Owned by: jstolarek
Priority: normal Milestone:
Component: Driver Version: 7.6.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

I would be happy to have automatic completion of command-line options in GHC. For that we need GHC to be able to list all its possible command line options, similarly to cabal's --list-options option.

Attachments (4)

0001-Add-show-options-to-list-all-flags-Fixes-7843.2.patch (4.8 KB) - added by jstolarek 23 months ago.
0001-Add-show-options-to-list-all-flags-Fixes-7843.patch (3.9 KB) - added by jstolarek 21 months ago.
Rebased on 9a2f8ccca172b5fe4333cabccffd6dffca1e5f98
Add-user-documentation-for-7843.patch (1.9 KB) - added by jstolarek 21 months ago.
Updates user documentation
Add-user-documentation-for-7843-no-filter.patch (2.5 KB) - added by jstolarek 21 months ago.
Updates user documentation AND removes the filter

Download all attachments as: .zip

Change History (22)

comment:1 Changed 23 months ago by jstolarek

  • Owner set to jstolarek

comment:2 Changed 23 months ago by jstolarek

  • Status changed from new to patch

comment:3 Changed 23 months ago by jstolarek

The patch adds --show-options option that displays all available options longer than two characters. Now it will be possible to use bash auto completion feature with GHC.

Please ignore the second patch - I forgot to mark the checkbox to overwrite the existing file when uploading the new version of my patch.

comment:4 Changed 21 months ago by jstolarek

Just reminding about the patch :) It would be great if someone could take a look and tell whether it's OK or not.

comment:5 Changed 21 months ago by ezyang

  • Status changed from patch to infoneeded

Hey Jan, sorry about the delay. It looks like the patch no longer applies to head; could you rebase it (and also squash the commits in the process?)

comment:6 Changed 21 months ago by jstolarek

Here's the new patch - I rebased it onto current master and squashed commits into one.

comment:7 Changed 21 months ago by jstolarek

  • Status changed from infoneeded to patch

comment:8 Changed 21 months ago by jstolarek

Bumping this up - before the patch gets out of sync again ;-)

comment:9 Changed 21 months ago by igloo

  • difficulty set to Unknown

Why do you filter out length 1 and 2 options?

comment:10 Changed 21 months ago by ezyang

Validating.

igloo: I can guess that it is because the point is for autocompletion, in which case it doesn't do you any good to autocomplete a length one option, since you have to already know what it is!

comment:11 Changed 21 months ago by igloo

Well, you may not be sure that the flag exists, and be looking at the list of completions.

Also, there's nothing about the command "ghc --show-options" that suggests that it is only for use by autocompletion. I would expect it would show all options.

So if the shorter options don't cause any problems, I'd suggest not including the filter.

comment:12 Changed 21 months ago by jstolarek

Except for what Edward pointed out, another reason why I decided to filter out short flags is that almost all of them require additional parameter (e.g. -H1G), which cannot be auto-completed. If you think that filter is unnecessary than of course it can be removed. I'm also not sure if removing filter will not cause any glitches - I think that some of the short options might have been duplicated on the list, but I'm not sure of that. I can provide new patch tomorrow - at the moment I'm getting some unexpected compilation errors.

comment:13 Changed 21 months ago by jan.stolarek@…

commit a28731b3a14ff6ef9c7dca8327d073e6ebb6b773

Author: Jan Stolarek <[email protected]>
Date:   Tue Jun 4 10:28:32 2013 +0200

    Add --show-options to list all flags (Fixes #7843)

 compiler/main/StaticFlags.hs |   13 ++++++++++---
 ghc/Main.hs                  |   21 ++++++++++++++++++++-
 2 files changed, 30 insertions(+), 4 deletions(-)

comment:14 Changed 21 months ago by simonpj

Thanks. Is the flag documented in the user manual?

Simon

Changed 21 months ago by jstolarek

Updates user documentation

Changed 21 months ago by jstolarek

Updates user documentation AND removes the filter

comment:15 Changed 21 months ago by jstolarek

Whops, I didn't think about that. I'm attaching two patches. First of them updates user documentation.

After playing a bit with autocompletion I think that the decision to exclude short options was wrong. Consider this example of autocmpletion without filtering out short options:

[killy@xerxes : ~] ghc -c
-c        -caf-all  -cpp

If the filter is used then the user will be hinted with only two last flags, which indeed might lead her to believe that there is no -c flag. Therefore I think that filter should be removed - my second patch updates the user documentation and removes the filter.

Also, without the filter the -O option is listed twice. I believe this is because -O can be used by itself and also with a parameter (e.g. -O2). Possible solutions are:

  • use nub
  • use some hack to remove this single option
  • ignore it, because shell will not list duplicates anyway:
    [killy@xerxes : ~] ghc -O
    -O     -Odph  -Onot
    

Since nub is O(n2) and I don't like hacks I chose the third option.

comment:16 Changed 21 months ago by jstolarek

Bump. I think it would be good to apply the second patch before it gets out of sync with HEAD.

comment:17 Changed 21 months ago by jan.stolarek@…

commit 2280f9651ea4f08d8d7c29affbb134d6769e42e0

Author: Jan Stolarek <[email protected]>
Date:   Fri Jun 7 09:15:32 2013 +0200

    --show-options lists all flags. Add user documentation for #7843

 docs/users_guide/flags.xml |    6 ++++++
 docs/users_guide/using.xml |   12 ++++++++++++
 ghc/Main.hs                |    2 +-
 3 files changed, 19 insertions(+), 1 deletions(-)

comment:18 Changed 21 months ago by igloo

  • Resolution set to fixed
  • Status changed from patch to closed

Applied, thanks!

Note: See TracTickets for help on using tickets.