Skip to content

Generate Shell completions#388

Merged
jessebraham merged 9 commits into
esp-rs:mainfrom
SergioGasquez:feature/shell-completions
Apr 19, 2023
Merged

Generate Shell completions#388
jessebraham merged 9 commits into
esp-rs:mainfrom
SergioGasquez:feature/shell-completions

Conversation

@SergioGasquez
Copy link
Copy Markdown
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)

@SergioGasquez SergioGasquez linked an issue Apr 17, 2023 that may be closed by this pull request
Copy link
Copy Markdown
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