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 Shell completions #388

Merged
merged 9 commits into from
Apr 19, 2023

Conversation

SergioGasquez
Copy link
Member

@SergioGasquez SergioGasquez commented Apr 17, 2023

Uses clap_complete to generate shell completions. Usage example:

espflash completions bash > /usr/share/bash-completion/completions/espflash.bash

Note for cargo-espflash the completions have to be appended to the cargo completions

Test

These are the test that I did in my environment (using Linux and fish shell).

espflash

  1. Install the crate from my branch:
    cargo install espflash --git https://github.com/SergioGasquez/espflash --branch feature/shell-completions
  2. Generate completions:
    espflash completions fish > espflash.fish
  3. Move the generated completions:
    sudo mv espflash.fish /usr/share/fish/completions/espflash.fish
  4. Here is the result of writing espflash and tabbing:
    ❯ espflash
    board-info                    (Establish a connection with a target device)
    completions                      (Generate completions for the given shell)
    flash                             (Flash an application to a target device)
    help            (Print this message or the help of the given subcommand(s))
    monitor                          (Open the serial monitor without flashing)
    partition-table                          (Operations for partitions tables)
    save-image           (Save the image to disk instead of flashing to device)
    write-bin  (Writes a binary file to a specific address in the chip's flash)

cargo-espflash

  1. Install the crate from my branch:
    cargo install cargo-espflash --git https://github.com/SergioGasquez/espflash --branch feature/shell-completions
  2. Generate completions:
    cargo espflash completions fish > cargo-espflash.fish
  3. Append the generated completions to cargo's completions:
    sudo cat cargo-espflash.fish >> /usr/share/fish/completions/cargo.fish
  4. Here is the result of writting cargo espflash and tabbing:
    ❯ cargo espflash completions fish > cargo-espflash.fish
    board-info           (Establish a connection with a target device)
    completions             (Generate completions for the given shell)
    flash          (Build and flash an application to a target device)
    help   (Print this message or the help of the given subcommand(s))
    monitor                 (Open the serial monitor without flashing)
    partition-table                 (Operations for partitions tables)
    save-image  (Save the image to disk instead of flashing to device)

Copy link
Member

@jessebraham jessebraham left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@jessebraham jessebraham merged commit f262403 into esp-rs:main Apr 19, 2023
@SergioGasquez SergioGasquez deleted the feature/shell-completions branch April 19, 2023 15:11
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.

Feature request: tab completion for shells (zsh, bash, ...)
2 participants