lima
lima copied to clipboard
Remove dependency on github.com/lithammer/dedent
This PR removes github.com/lithammer/dedent dependency which is used only for the limactl list command. It's not worth to import the whole package for the one function dedent#Dedent.
The output of the limactl list -h is not changed.
Running `limactl list -h` before the PR changes:
> make _output/bin/limactl && _output/bin/limactl list -h
...
List instances of Lima.
The output can be presented in one of several formats, using the --format <format> flag.
--format json - output in json format
--format yaml - output in yaml format
--format table - output in table format
--format '{{ <go template> }}' - if the format begins and ends with '{{ }}', then it is used as a go template.
These functions are available to go templates:
indent <size>: add spaces to beginning of each line
missing <message>: return message if the text is empty
The following legacy flags continue to function:
--json - equal to '--format json'
...
Running `limactl list -h` with this PR changes:
> make _output/bin/limactl && _output/bin/limactl list -h
...
List instances of Lima.
The output can be presented in one of several formats, using the --format <format> flag.
--format json - output in json format
--format yaml - output in yaml format
--format table - output in table format
--format '{{ <go template> }}' - if the format begins and ends with '{{ }}', then it is used as a go template.
These functions are available to go templates:
indent <size>: add spaces to beginning of each line
missing <message>: return message if the text is empty
The following legacy flags continue to function:
--json - equal to '--format json'
...
"The whole package" is actually not all that big: (the README is longer)
https://github.com/lithammer/dedent/blob/v1.1.0/dedent.go
The goal was to make the code more readable, similar to python dedent.
https://docs.python.org/3/library/textwrap.html#textwrap.dedent
Previously it was naturally indented, which made the output "wrong": 5c01a402a773cb91521896b78f68c087bf58f05e
Thank you for the detailed explanation and links behind introducing Dedent.
Incorporating this dependency contradicts the Go idiom "A little copying is better than a little dependency". We can easily avoid this dependency without harming readability and this PR shows how. Removing the dedent makes the list implementation consistent with other commands.
I'm OK with breaking indendation, was just trying to explain why it was the way it was.
@lima-vm/maintainers PTAL
Let me merge this