Ordering lists of objects in the CF CLI


Greg Oehmen
 

Hey All:

The CLI team has recently been chewing on ordering sets of objects like
orgs and apps. We've gotten a couple PRs [0] recently related to this.
I've been asking internally around CF teams about the value here with mixed
results and would like to hear some input from the OSS community.

Currently, lists are returned in ccdb insert order which basically means
oldest (first inserted) to newest (most recently inserted). The CC API has
an order-direction parameter which enables you to reverse that order and
see objects newest to oldest.

If we wanted to enable the ordering of a return set, there are a couple
options:


1. Keep the default order as it currently is natively sent by the CC API.
Add two flags to any 'list' command for desc & asc:

`cf orgs --asc` --> sorts in (A-Z, 1-9) order
`cf orgs --desc` --> sorts in (Z-A, 9-1) order



2. Change the default order to descending in the CF CLI and add a single
flag to reverse order (see --asc in option 1 above). This would mean that
the object list is always returned to the CLI user in descending order.
But is there any value here? How often would you use the '--asc' flag? In
this scenario, would you then want the CLI to include a flag to return
object lists in the order that is native to the CC API?


Then there is always the option to do nothing. If there is not as much
perceived value here in the OSS community, then not changing anything is
always an option.


Here is the set of all CF CLI commands that return lists of objects. If we
opt for 1 or 2 above, we would apply that option to this entire set (which
is ironically not in any sort order).

apps
stacks
services
service-keys
orgs
spaces domains
routes
buildpacks
org-users
space-users
quotas
space-quotas
service-auth-tokens
service-brokers
security-groups
staging-security-groups
running-security-groups
plugins
list-plugin-repos
repo-plugins



Also - I know that the desc & asc sort order is more complex than my
example above (a-z, 0-9) due to upper/lower case, non-alphanumeric, etc.
We will follow standard linux sort order convention.


Last thing - Conversations so far have not even taken CF CLI
internationalization into account. This may turn out to be waaaaaay harder
than it seemed. That's why I'm trying to gauge perceived value. Will this
change make your life easier and make you a more effective user of the CF
CLI?

Thanks

[0] https://github.com/cloudfoundry/cli/pull/481,
https://github.com/cloudfoundry/cli/pull/457

Greg Oehmen
Cloud Foundry Product Manager
415.205.6596

Join cf-dev@lists.cloudfoundry.org to automatically receive all group messages.