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

generate completions #753

Merged
merged 2 commits into from
Jan 14, 2024
Merged

generate completions #753

merged 2 commits into from
Jan 14, 2024

Conversation

BoostCookie
Copy link
Contributor

@BoostCookie BoostCookie commented Nov 15, 2023

EDIT:
This is done now. It solves #151. It works the same way as it does in rustup. https://rust-lang.github.io/rustup/installation/index.html

OLD MESSAGE:

This is some starting effort that can eventually solve #151.
I don't know how the build files are being packaged for the different distributions and operating systems. I'm asking for feedback in this regard.

What happens now:
Every time the package is build the completions for the different shells are generated and put into the build directory target/release/build/juliaup-<somehexstring>/out/.

What is left to do:
Add the completions to the packages so that they are available after installing juliaup.

@davidanthoff
Copy link
Collaborator

I'm not really familiar with how completion files work. Do we need to drop them into a specific location on user systems? Or do they need to be run? Or something else?

@BoostCookie
Copy link
Contributor Author

BoostCookie commented Nov 16, 2023

I'm not really familiar with how completion files work. Do we need to drop them into a specific location on user systems? Or do they need to be run? Or something else?

Packages usually install their zsh completions to /usr/share/zsh/site-functions/. If you are an admin that installs stuff manually you should use /usr/local/ instead of /usr/ of course.
Similarly bash completions go into /usr/share/bash-completion/completions/.

So OS repositories (Arch User Repository, openSUSE Tumbleweed, Solus) should definitely package the completions into these directories.

For the "recommended" install method

curl -fsSL https://install.julialang.org | sh

we are only the local user. We could put the completions somewhere in $JULIA_DEPOT_PATH and then do something similar like here

pub fn add_binfolder_to_path_in_shell_scripts(bin_path: &Path) -> Result<()> {
where we add the juliaup binary directory to $PATH. => We can add our completions directory to the specific shell completions.

Though personally I'm not a fan of fishing around in people's config files. I think we should do it the way rustup does it.
https://rust-lang.github.io/rustup/installation/index.html
With a command

$ juliaup completions bash > ~/.local/share/bash-completion/completions/juliaup

for bash, for example.

@BoostCookie
Copy link
Contributor Author

I have now followed the rustup way, and added a command that generates the completions.

@BoostCookie BoostCookie changed the title automatically generate completions during build generate completions Nov 26, 2023
src/bin/juliaup.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Looks good to me, and is quite useful!

@fingolfin
Copy link
Contributor

@BoostCookie unfortunately it seems this now as conflicts that must be resolved?

@BoostCookie
Copy link
Contributor Author

Is there even any interest in this pull request?
@davidanthoff

@StefanKarpinski
Copy link
Sponsor Member

Yes, this is great functionality. @davidanthoff is quite busy, but please don't be discouraged. We'll get this merged.

@davidanthoff
Copy link
Collaborator

We had more changes to the clap structures on main, and I'm a bit worried that those changes might get lost in the simultaneous move of the code to a new file in this PR. So, I just created a new PR off main that just moves the clap structs to a new file, like in this PR. I'm going to merge that right away, and then we can be entirely sure that we don't lose anything in the merge story.

@BoostCookie could you rebase this PR on top of main once I've merged #787?

Awesome PR, thanks!

The command generates the shell completions file for juliaup.
For example, to generate the completions for Bash and save them to a
file you can run
```
juliaup completions bash > ~/.local/share/bash-completion/completions/juliaup
```
Then you can source this file in your bashrc.
@davidanthoff davidanthoff merged commit b713fbc into JuliaLang:main Jan 14, 2024
23 checks passed
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.

4 participants