Nexmo / nexmo-cli

Nexmo CLI (Command Line Interface)
https://nexmo.com
MIT License
78 stars 52 forks source link

Updating `nexmo numbers:list` to provide paging information in output #122

Closed leggetter closed 7 years ago

leggetter commented 7 years ago

Via support:

CLI command nexmo nl doesn't indicate there are more numbers than the first 10. Customer states: I had to research the CLI documentation to see that there are –size and –page parameters and that the CLI won’t inform me there are more than 10 records when I run a “nexmo nl” CLI command. it would be beneficial that the CLI could return some kind of information that might let you know what page you are on out of total pages or something of that nature. Had I received a “page 1 of 2” or something like that, it would have been obvious there were more numbers there.

Customer recommends CLI return something like 'page 1 of 2'

cbetta commented 7 years ago

@leggetter so there's some thought that has gone into this.

In general, any command without -v returns something that can be easily parsed/piped into another method.

So in the case of numbers:list it just returns numbers, which you can then parse to find the right numbers, etc:

nexmo nl
442039051100
447520619323

nexmo nl | grep 2 
447520619323

By adding -v to a method we do not just add more info, but also more UI to the response:

Item 1-10 of 2

msisdn       | country | type       | features  | voiceCallbackType | voiceCallbackValue                   | moHttpUrl | voiceStatusCallbackUrl
-----------------------------------------------------------------------------------------------------------------------------------------------
442039051100 | GB      | landline   | VOICE     | app               | 91064c2b-abcd-abcd-abcd-f00000000 | undefined | undefined             
447520619323 | GB      | mobile-lvn | VOICE,SMS | undefined         | undefined                            | undefined | undefined  

In other words, I understand the customer's request, but making the requested change would break from the standard across all methods.

One solution would be to by default return the verbose result, and instead add a -q (quiet) flag for those who need it.

leggetter commented 7 years ago

Really good point and good suggestion.

I think all commands should behave in the same way. If one of the goals is to ensure the output can be piped into another command then sending the verbose output by default makes that more difficult.

Would adding a line to the start or end that had paging information be a hinderance to this goal? It would mean it'd have to be stripped, but I'd assume that's not difficult? Or should you always avoid metadata?

Aside: Item 1-10 of 2 could be confusing. It does mean pages but it's in the context of "Item". So maybe it should say Item 1-10. Page 1 of 2. or similar.

cbetta commented 7 years ago

Regarding the aside, that's a bug ;)

Regarding the main issue: yeah not sure. It would have to be stripped indeed. It would also break backwards compatibility massively for anyone currently using the CLI in this way.

cbetta commented 7 years ago

Alternative idea:

Let's up the default page size for the CLI to the max. This means only people with a lot of numbers will have this issue, which is a pretty small group of people I guess?

cbetta commented 7 years ago

This is also related to #51

sammachin commented 7 years ago

I like this idea of upping the default to the max in a request, I think its 100?