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

Bash autocompletion for Geth #24145

Closed
willianpaixao opened this issue Dec 22, 2021 · 8 comments
Closed

Bash autocompletion for Geth #24145

willianpaixao opened this issue Dec 22, 2021 · 8 comments

Comments

@willianpaixao
Copy link
Contributor

Rationale

Why should this feature exist?

Geth has a huge number of commands and options to be passed. Some commands need arguments and sometimes it's complicated to say which order you need to provide.

A Bash completion script would give hints of what can be expected when pressing TAB.

What are the use-cases?

Every Geth developer or beginner that often uses Geth's CLI.

Implementation

Do you have ideas regarding the implementation of this feature?
Two approaches can be taken:

  1. A new geth command is created, eg. geth completion, that dumps a completion script. When installing Geth, the uses adds source <(geth completion) to their ~/.bashrc or runs geth completion > /etc/bash_completion.d/geth.
  2. A completion script is written and included in this repository. Then the Geth documentation will guide the user to download the script and place it under ~/.bash_completion.d/geth or /etc/bash_completion.d/geth. In this option, no Go source code will be changed.

Are you willing to implement this feature?
Yes.

References

@edualb
Copy link
Contributor

edualb commented Jan 12, 2022

I have been working on this Feature Request and I figured out that geth uses this library to manage the geth cli:

gopkg.in/urfave/cli.v1

This library explains how could we do that with a bash script. I tried it yesterday and worked 🎉 . However it is necessary to run a script depend on your platform:

For that, I have been thinking include a tutorial page in gh-page explaning how you can configure your autocomplete depend on your platform. What you think guys?

@ligi
Copy link
Member

ligi commented Jan 30, 2022

I just tried it out on linux with bash and it is actually really nice - thanks for bringing this up!

image

prepared it with #24313 - but would really appreciate if you do the tutorial as you offered.

@edualb
Copy link
Contributor

edualb commented Jan 31, 2022

@ligi Yeah, of course! I have some issues to solve this week but I will be available next week. If someone else would like to implement it this week be free, however, if no one implement it until there, I'll do that 😉

@ligi
Copy link
Member

ligi commented Feb 15, 2022

@edualb still interested in writing something?

@edualb
Copy link
Contributor

edualb commented Feb 15, 2022

@ligi Yeah! I am, but I have faced a problem when I tried to include a new page... I am on my job now and in the end of my shift I will put my issue here... If you can help I would be glad for that 💙

@ligi
Copy link
Member

ligi commented Feb 15, 2022

ya - LMK what problem you faced and I will try to find a way around it

@edualb
Copy link
Contributor

edualb commented Feb 16, 2022

@ligi sorry for my delay 🤐

I realized that my docker had an old image and my Bash Autocomplete tutorial never worked hehe I just purge this image and tried again, everything worked well 🎉

image

holiman pushed a commit that referenced this issue Mar 15, 2022
sidhujag pushed a commit to syscoin/go-ethereum that referenced this issue Mar 16, 2022
JacekGlen pushed a commit to JacekGlen/go-ethereum that referenced this issue May 26, 2022
@fjl
Copy link
Contributor

fjl commented Jun 30, 2022

We now ship bash completions in the Ubuntu package.

@fjl fjl closed this as completed Jun 30, 2022
cp-wjhan pushed a commit to cp-yoonjin/go-wemix that referenced this issue Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants
@fjl @ligi @willianpaixao @edualb and others