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

feature: add command-line completions #131

Merged
merged 1 commit into from
Sep 22, 2024
Merged

feature: add command-line completions #131

merged 1 commit into from
Sep 22, 2024

Conversation

Jisu-Woniu
Copy link
Contributor

@Jisu-Woniu Jisu-Woniu commented Sep 16, 2024

Trying to add command-line completions.

Closes #130

@Jisu-Woniu
Copy link
Contributor Author

There is an issue when building if I try to generate completions in build.rs:

The LONG_VERSION variable here:

https://github.com/Jisu-Woniu/typstyle/blob/43ead3fb62c635c844b26a51265d1297b73b137b/src/cli.rs#L10

https://github.com/Jisu-Woniu/typstyle/blob/43ead3fb62c635c844b26a51265d1297b73b137b/src/cli.rs#L64

Is not accessible since VERGEN_CARGO_TARGET_TRIPLE is not available during build.

@Jisu-Woniu Jisu-Woniu marked this pull request as ready for review September 16, 2024 05:29
@Jisu-Woniu
Copy link
Contributor Author

The code now compiles, but cli.rs seems quite ugly now...

@Enter-tainer
Copy link
Owner

I will review this pr when i am back from vacation (20th)

@Enter-tainer
Copy link
Owner

I will look into it this weekend

src/cli.rs Outdated Show resolved Hide resolved
Copy link
Owner

@Enter-tainer Enter-tainer left a comment

Choose a reason for hiding this comment

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

overall LGTM.

src/main.rs Show resolved Hide resolved
Copy link
Owner

@Enter-tainer Enter-tainer left a comment

Choose a reason for hiding this comment

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

thank you!

@Enter-tainer Enter-tainer enabled auto-merge (rebase) September 22, 2024 03:33
@Enter-tainer Enter-tainer merged commit b275dd0 into Enter-tainer:master Sep 22, 2024
11 checks passed
@Jisu-Woniu
Copy link
Contributor Author

There is a problem when I revert the changes, the generated completions are using the wrong binary name.

@Jisu-Woniu
Copy link
Contributor Author

Jisu-Woniu commented Sep 22, 2024

For example, if I run cargo run -- completions bash, what I get is:

_target/debug/typstyle() {
    local i cur prev opts cmd
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    cmd=""
    opts=""

    for i in ${COMP_WORDS[@]}
    # ...

which is expected to be:

_typstyle() {
    # ...

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.

Add shell completion with clap_complete
2 participants