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

fish shell completions #912

Open
thernstig opened this issue May 10, 2020 · 12 comments
Open

fish shell completions #912

thernstig opened this issue May 10, 2020 · 12 comments
Labels
enhancement New feature or enhancement help wanted Extra attention is needed packaging

Comments

@thernstig
Copy link

It would be amazing if httpie could default-install completions for the awesome fish shell.

Reference: https://fishshell.com/docs/current/#where-to-put-completions

Example of other great tools that does this:

ll  /usr/share/fish/vendor_completions.d
.rw-r--r-- 4.4k root root 25 Apr 13:48 bat.fish
.rw-r--r--  51k root root 11 Mar  2:24 docker.fish
.rw-r--r--  12k root root  9 May 17:38 rg.fish
@exploide
Copy link
Contributor

I see the problem here that httpie is not really responsible for the installation process. This is done by the package maintainers of your Linux distribution (if you installed from the repositories as advised in the README).

Hence, a packaging request would need to be filed at the respective distribution's issue tracker.

For example, I filed a request for Fedora: https://bugzilla.redhat.com/show_bug.cgi?id=1834441

@thernstig
Copy link
Author

thernstig commented May 11, 2020

Is there really no way for httpie to add to what is unpacked in the installation process, and default-including the completions file?

Edit: I see now that the completion does exist here https://github.com/jakubroztocil/httpie/blob/master/extras/httpie-completion.fish - but it still seems very inefficient to have to request this to be installed by every distribution.

@thernstig
Copy link
Author

thernstig commented May 11, 2020

I would also say that the request you made should be updated. For the fish shell, the default should be to install them into XDG_DATA_DIRS and only secondly try /usr/share/fish/vendor_completions.d/.

@jkbrzt
Copy link
Member

jkbrzt commented May 12, 2020

I guess having a packaging guide of sorts would make it easier for maintainers to produce better packages.

The only kind-of-official non-PyPi package is the Homebew formula, and I now realise that not even there the completions get installed.

I assume that there’s no reliable way to install the *shell completions with pip.

@exploide thanks for the Fedora request 👍

@exploide
Copy link
Contributor

I would also say that the request you made should be updated. For the fish shell, the default should be to install them into XDG_DATA_DIRS and only secondly try /usr/share/fish/vendor_completions.d/.

You mean a XDG_DATA_DIRS that contains a (different) system-wide directory? The package maintainers know where these paths are in their distribution and how to retrieve them. When bulding the package, for example using Fedora spec files, they would use %{_datadir} as a variable that points to the correct directory. We don't need to tell them and it will almost always be /usr/share anyways.

Is there really no way for httpie to add to what is unpacked in the installation process, and default-including the completions file?

it still seems very inefficient to have to request this to be installed by every distribution.

Depends on what you mean with installation process. One can install httpie via different means. If you use your Linux distribution's package management, then it's up to them. httpie is not involved in the packaging process. That's how it works.

I guess having a packaging guide of sorts would make it easier for maintainers to produce better packages.

That could be helpful. Some projects even maintain the spec file for RPM and whatever is needed for DEB packages in their repository. But distro maintainers would need to pick that up and coordinating effort would be necessary. Don't know how feasible that is right now.

I assume that there’s no reliable way to install the *shell completions with pip.

In theory, setup.py could install it because it can run arbitrary code. But this is enormously uncommon I think. Don't know if the Python Packaging Authority has a statement concerning that. But I can imagine that becomes horrible. Where to install the file in which case, what about virtualenv and for uninstalling there is no way?!

The only kind-of-official non-PyPi package is the Homebew formula

While I have literally no experience with MacOS X and Homebrew, I think I have read something about homebrew packages installing autocompletion files somehow.

@thernstig
Copy link
Author

Ok, I did not know it was this involved. Reading the repos of other tools such as fd, hyperfine, bat etc. I could not find anything related to that they had to request this from package maintainers, but not saying they haven't. We all learn something new every day 😄

@exploide
Copy link
Contributor

exploide commented May 13, 2020

Additionally, things become different for other programming languages and environments. The Rust tool fd for example generates the completion files automatically using Clap. The fd project then creates own deb packages with its CI system. This deb will of course contain the autocompletion files. But there is no guarantee Debian, Ubuntu and the others produce the package the same way. On the other hand, rpm packages are not produced by fd's CI. Fedora maintains the necessary spec file by its own and incorporates the completion files there explicitly.

Packaging is a mess 🙄

PS: It is not always necessary to request that from package maintainers. Often they find the files by themselves within the source and include them. But they are all human beings and some don't care initially about shell completions and some others have no idea what the heck fish is 😄

@mqudsi
Copy link

mqudsi commented May 23, 2020

Fish core developer here.

We are always happy to upstream completions directly into the fish codebase, if you like. Fish ships with hundreds of hand-written "dynamic" completions that go far beyond merely state-machine-based deduction of autocompletion parameters and can provide "dynamic" logic based on introspecting the command line and even executing commands at runtime (e.g. the aws s3 completions allow you tab-complete s3 paths by executing s3 ls and parsing the results incrementally).

@exploide
Copy link
Contributor

Oh yes, apparently I forgot to mention this option despite I recently contributed completions to fish by myself 😄

So if the httpie project would like to hand over the completion file to fish itself, that would make things more seamless for fish users.

A possible drawback to note: It can then happen that the installed version of httpie is not in sync with the file installed with the version of fish. Users could see outdated or missing options from the completion. Don't know if this is negligible since currently most fish users have no httpie completions at all (despite the autogenerated ones).

@jkbrzt
Copy link
Member

jkbrzt commented May 24, 2020

Thanks for dropping in, @mqudsi! Including the completions in the fish codebase would indeed be the most robust solution. @exploide’s note about the possible version mismatch is valid, though—is there a standard way of dealing with that, e.g., by supporting multiple versions of the command being autocompleted simultaneously?

@exploide
Copy link
Contributor

is there a standard way of dealing with that, e.g., by supporting multiple versions of the command being autocompleted simultaneously?

I would not call that a standard way but yes. Some completion files that suffer the same problem try to solve that by checking --version and offer some options only when appropriate.

@jkbrzt
Copy link
Member

jkbrzt commented May 24, 2020

I’m playing with idea of providing a built-in API for the shell completions (maybe using something like @kislyuk’s https://github.com/kislyuk/argcomplete). Then the shell-specific completions scripts could be pretty minimal and hopefully version agnostic.

@BoboTiG BoboTiG added the help wanted Extra attention is needed label Oct 7, 2021
@isidentical isidentical added the enhancement New feature or enhancement label Dec 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement help wanted Extra attention is needed packaging
Projects
None yet
Development

No branches or pull requests

6 participants