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

add dynamic completion #1509

Merged
merged 22 commits into from
Oct 18, 2021
Merged

add dynamic completion #1509

merged 22 commits into from
Oct 18, 2021

Conversation

umbynos
Copy link
Contributor

@umbynos umbynos commented Oct 13, 2021

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce?

command line completion enhancement
close #1452 close #649

  • What is the current behavior?

Command line completion works in a static way for now. Except for #1431

  • What is the new behavior?

Dynamic command line completion has been added to a lot of commands and flags, this should enhance a lot the experience in using the CLI. Further details in #1452

no

  • Other information:

See how to contribute

@umbynos umbynos added type: enhancement Proposed improvement topic: code Related to content of the project itself topic: CLI Related to the command line interface labels Oct 13, 2021
@umbynos umbynos requested a review from a team October 13, 2021 15:57
@umbynos umbynos self-assigned this Oct 13, 2021
@umbynos
Copy link
Contributor Author

umbynos commented Oct 14, 2021

asciicast
Here's a little demo.

@umbynos
Copy link
Contributor Author

umbynos commented Oct 14, 2021

In the following table there is the full list of completion added:
The 🚧 means that have been added in this PR
The 🔵 means that test for that functionality have been added
The ❎ means that this functionality won't be added

Command Subcommand flagname completion comments implemented
board attach   port || fqbn    
  details -b fqbn   🚧 ✔️ 🔵
  search   fqbn or other is it usefull??
burn-bootloader   -b fqbn   🚧 ✔️
    -l protocol   🚧:heavy_check_mark: :large_blue_circle:
    -P programmer   🚧:heavy_check_mark: :large_blue_circle:
    -p port doesn’t return the network ports ​🚧​ ✔️
compile   -b fqbn   ✔️ 🔵
    -l protocol   🚧✔️ 🔵
    -P programmer   🚧✔️ 🔵
    -p port doesn’t return the network ports ​🚧​✔️
completion     type static ✔️
config add   property   🚧 ✔️ 🔵
  remove   property   🚧✔️🔵
  delete   property maybe return also the key before the dot 🚧✔️🔵
  set   property   🚧✔️🔵
core download   packager:arch does not complete the version ​🚧✔️​🔵
  install   packager:arch does not complete the version 🚧✔️🔵
  uninstall   packager:arch   🚧✔️ 🔵
debug   -b fqbn   🚧✔️ 🔵
    -l protocol   🚧✔️ 🔵
    -P programmer   🚧✔️ 🔵
    -p port doesn’t return the network ports ​🚧​ ✔️
    --interpreter console-type  
lib deps   LibraryName   🚧✔️ 🔵
  download   LibraryName   🚧​ ✔️ 🔵
  examples   LibraryName   🚧 ✔️ 🔵
  examples -b fqbn   🚧 ✔️ 🔵
  install   LibraryName   🚧 ​✔️ 🔵
  uninstall   LibraryName   🚧 ✔️ 🔵
monitor   -b fqbn   🚧​ ✔️ 🔵
    -l protocol   🚧​ ✔️ 🔵
    -p port   🚧​ ✔️
    -c config of the port Difficult to implement due to the format of the args
upload   -b fqbn   🚧 ✔️ 🔵
    -l protocol   🚧✔️ 🔵
    -P programmer   🚧✔️ 🔵
    -p port doesn’t return the network ports ​🚧​ ✔️

In the following table there are static flags

flagname completion Comment Implemented
--format {text|json} static 🚧​✔️ 🔵
–log-format {text|json} static 🚧​✔️ 🔵
--log-level trace-debug…. static 🚧​✔️ 🔵

cli/cli.go Outdated Show resolved Hide resolved
Copy link
Contributor

@silvanocerza silvanocerza left a comment

Choose a reason for hiding this comment

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

That are some changes to make, but all in all I like it. Good job son. 💯

as of now this parameter is useless because if a string is typed in the terminal it cannot be swapped with a different one.
For example if I write `arduino-cli compile -b avr<TAB><TAB>` the completion function returns all elements starting with `arduino:avr...`.
So the completions are not showed because they cannot be swapped with a string that starts differently.
The only shell which seems to support this seems to be zsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: CLI Related to the command line interface topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
2 participants