cli icon indicating copy to clipboard operation
cli copied to clipboard

allow sorting to be configured globally (closes #418)

Open cedi opened this issue 3 years ago • 2 comments

I am a heavy user of the hcloud-cli. However, I really don't like the default sorting by server-id, and would prefer sorting by age (see #417/#420) or name.

Currently, I always type hcloud server list -s name to sort by name.

since the -s flag is part of the list subcommand and not the hcloud base command (like in many other software that makes use of the Cobra framework), I cannot simply alias hcloud-"hcloud -s name" in my shell to default the sorting to "by name".

This commit adds a [defaults] section to the config toml which allows to override the default sorting behavior for individual hcloud subcommands.

The following behavior is used to determine the sorting-order

config file flag result
not-set not-set sort by id (default)
not-set set sort by flag value
set not-set sort by config value
set set sort by flag value

cedi avatar Nov 16 '22 22:11 cedi

This PR has been marked as stale because it has not had recent activity. The bot will close the PR if no further action occurs.

github-actions[bot] avatar Feb 16 '23 12:02 github-actions[bot]

This PR has been marked as stale because it has not had recent activity. The bot will close the PR if no further action occurs.

github-actions[bot] avatar May 18 '23 12:05 github-actions[bot]

#795 will add the feature you described. Changes to how the configuration works were necessary to allow for a clean and extendable implementation. Here's how you will be able to set default sorting columns when #795 is merged and released:

$ hcloud config set sort.server name
Set 'sort.server' to '[name]' in context 'main'

Since this PR is stale and now outdated, I will close it. Thanks for your contribution and bringing this feature idea forward!

phm07 avatar Jul 10 '24 11:07 phm07