Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add support for shell completion #340

Merged
merged 4 commits into from
Jul 19, 2018
Merged

Conversation

chevdor
Copy link
Contributor

@chevdor chevdor commented Jul 16, 2018

The Polkadot cli command now supports shell auto-completion.
The auto-completion is now generated from the build. Once executed, this script show the following if you type polkadot <tab><tab>:

$ polkadot 
--base-path      --collator       --help           --light          --no-telemetry   --pruning        --telemetry-url  --ws-port        -h               build-spec       import-blocks    
--bootnodes      --dev            --key            --log            --node-key       --rpc-port       --validator      -V               -l               export-blocks    
--chain          --execution      --keystore-path  --name           --port           --telemetry      --version        -d               -t               help     

The completion script is generated from cli.yml so it will keep in sync as the command and flags evolve.

See it in action below:
asciicast

Assuming you built a release version using cargo build --release and use bash run the followig:

source target/release/completion-scripts/polkadot.bash

You can find completion scripts for:

  • bash
  • fish
  • zsh
  • elvish
  • powershell

@chevdor chevdor force-pushed the completion branch 11 times, most recently from dd75772 to 5b902e8 Compare July 16, 2018 23:17
@chevdor chevdor changed the title WIP: Add support for completion scripts Add support for shell completion scripts Jul 17, 2018
@chevdor chevdor changed the title Add support for shell completion scripts Add support for shell completion Jul 17, 2018
@tomusdrw
Copy link
Contributor

Maybe better to add a CLI option to generate that in runtime?

polkadot cli-completion > polkadot.bash

Makes different version management easier, since you just obtain the binary and generate the completions for yourself locally.

@chevdor
Copy link
Contributor Author

chevdor commented Jul 17, 2018

Hi @tomusdrw, thanks for your feedback.

I was considering it but went for a build only option in order to not overload the cli with code that is used only once at most and keep the polkadot cli as slim as possible but this is something that can be changed of course.

It may be even worth having this as feature.

If we decide to augment the cli, we will also need to pass and validate the shell:

polkadot cli-completion bash > polkadot.bash
polkadot cli-completion powershell > polkadot.ps1
...

README.md Outdated

The Polkadot cli command supports shell auto-completion. For this to work, you will need to run the completion script matching you build and system.

Assuming you built a release version using `cargo build --release` and use `bash` run the followig:
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: followig

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed.


fs::create_dir(&path).ok();

// println!("{:?}", path);
Copy link
Contributor

Choose a reason for hiding this comment

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

remaining commented println

@gavofyork gavofyork merged commit f6e1d5d into paritytech:master Jul 19, 2018
lamafab pushed a commit to lamafab/substrate that referenced this pull request Jun 16, 2020
* Update Substrate

* Update Substrate again

* Integrate weight/fee stuff.

* Add new files.
JoshOrndorff pushed a commit to moonbeam-foundation/substrate that referenced this pull request Apr 21, 2021
* Set 'opt-level = 0' for release builds

* Use 'opt-level = 3' in CI
liuchengxu added a commit to chainx-org/substrate that referenced this pull request Aug 23, 2021
* Check feature runtime-benchmarks in CI

* Fix runtime-benchmarks building
liuchengxu pushed a commit to autonomys/substrate that referenced this pull request Jun 3, 2022
…up-part-9

Secondary chain cleanup part 9
helin6 pushed a commit to boolnetwork/substrate that referenced this pull request Jul 25, 2023
* Add timestamp pallet test

* Remove println

* Make timestamp test more reliable
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
SDK Node (deprecated)
  
Awaiting triage
Development

Successfully merging this pull request may close these issues.

None yet

4 participants