Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support hyperlinks in search output #401

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

avdv
Copy link

@avdv avdv commented Mar 12, 2023

Add --hyperlink flag to search sub command which outputs ANSI escape sequences
that supporting terminal emulators can leverage to show hyperlinked text.

Rendered help text:

cabal-install -- run -- hoogle search --help
Up to date
Hoogle 5.0.18.3, https://hoogle.haskell.org/

hoogle [search] [OPTIONS] [QUERY]
  Perform a search

Flags:
     --colour --color   Use colored output (requires ANSI terminal)
     --json             Get result as JSON
     --jsonl            Get result as JSONL (JSON Lines)
  -l --link             Give URL's for each result
  -h --hyperlink        Hyperlink results with ANSI escape sequences
...

The effect depends on the terminal emulator used; I am using kitty and it underlines hyperlinked text with a squiggly line. A simple left click opens the default application for the link:
2023-03-12_15-59

See https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda for more info.

Add `--hyperlink` flag to search sub command which outputs ANSI escape sequences
that supporting terminal emulators can recognize.
@ndmitchell
Copy link
Owner

Thanks for the diff. What does this flag do on terminals that don't support it? I'm wondering if the answer is there is nothing harmful, we could just always emit the hyperlink if we are emitting ANSI codes anyway and not even have a flag?

@avdv
Copy link
Author

avdv commented Mar 13, 2023

Yes, a terminal emulator should just ignore ANSI escape sequences it does not recognize / support.

But when does hoogle emit ANSI codes? From a quick look, it never does that. E.g. the --color / --colour flag seems to have no effect (I couldn't find any usage of color in the code base except in CmdLine.hs).

And the CI seems to fail for an unrelated reason. Or do I have to update copyright years maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants