asdf-vm / asdf

Extendable version manager with support for Ruby, Node.js, Elixir, Erlang & more
https://asdf-vm.com/
MIT License
21.47k stars 767 forks source link

`asdf current` should set spacing dynamically #866

Open MetricMike opened 3 years ago

MetricMike commented 3 years ago

Is your feature request related to a problem? Please describe.

Some projects (hi, java!) use names that cause some overflow on the asdf current command.

metricmike@MTOWER:~/projects/dev-environment$ asdf current
awscli          ______          No version set. Run "asdf <global|shell|local> awscli <version>"
dotnet-core     5.0.102         /home/metricmike/.tool-versions
golang          1.15.8          /home/metricmike/.tool-versions
gradle          7.0-milestone-1 /home/metricmike/.tool-versions
java            corretto-11.0.10.9.1 /home/metricmike/.tool-versions
maven           3.6.3           /home/metricmike/.tool-versions

Describe the solution you'd like

asdf current should set its columns dynamically based on the plugins it's going to output

metricmike@MTOWER:~/projects/dev-environment$ asdf current
awscli          ______                    No version set. Run "asdf <global|shell|local> awscli <version>"
dotnet-core     5.0.102                   /home/metricmike/.tool-versions
golang          1.15.8                    /home/metricmike/.tool-versions
gradle          7.0-milestone-1           /home/metricmike/.tool-versions
java            corretto-11.0.10.9.1      /home/metricmike/.tool-versions
maven           3.6.3                     /home/metricmike/.tool-versions

Additional context

Happy to work on this myself, this issue is mostly a placeholder for me :)

jthegedus commented 3 years ago

Hey @MetricMike thanks for proposing this and volunteering to work on it. There's a lot of background to improving the terminal output. I will link here and encourage you to read before working on this.

column was previously added and removed as we cannot assume it is available on all machines:

Wrap terminal line outputs to 80 chars (https://github.com/asdf-vm/asdf/issues/646). This issue discusses:

The current implementation of asdf current uses printf with min padding on each col.

Knowing the max beforehand is difficult (not impossible obviously because column does its magic) and ultimately letting the terminal perform wrapping seems like the best option. Knowing what width is acceptable to the user and how to output accordingly is difficult as I am sure you can see.

Finally, a solution I (few have chimed in here) would like to see is one which we can apply everywhere: