martindstone / pagerduty-cli

A command line interface for PagerDuty
MIT License
91 stars 13 forks source link

add a `--max-responses` global field #26

Closed georgettica closed 2 years ago

georgettica commented 2 years ago

sometimes, our service is a bit bogged with details and I just need the header / the first few items.

 pd incident:list --team ${MYTEAM}
Getting incidents 1/19 👍, 0/19 👎... ⡿

could we add this

pd incident:list --team ${MYTEAM} --max-responses 20
Getting incidents 0/1 👍, 0/1 👎... ⡿
martindstone commented 2 years ago

That sounds like a good idea, I'll do it

georgettica commented 2 years ago

any update?

martindstone commented 2 years ago

Hi @georgettica I have not had a chance to do this yet, blame my day job! But I should be able to get to it pretty soon, say within the next week or so...

georgettica commented 2 years ago

I won't blame it, but I am glad to see you know it's there and have it somewhere on your roadmap

martindstone commented 2 years ago

hey @georgettica i finally got it implemented. Could you update to the RC (pd update rc to use the RC, pd update stable to go back to the stable version) and check it out? What I did was I added a --limit flag to all the list commands and to rest fetch. Let me know what you think.... thanks...

georgettica commented 2 years ago

I logged of, but as I am so excited for this I am logging in to check this!

georgettica commented 2 years ago

yes! this is great :)

but I was not able to fully test this as the endpoint by default now cuts at 25 responses. but if I set the --limit to be high it happens

georgettica commented 2 years ago

as noted here https://github.com/martindstone/pagerduty-cli/blob/bf1eaf75471b1582cbe3aa79edfc0feee10b0fc4/src/pd.ts#L362

georgettica commented 2 years ago

could I also get the --all field so I can choose when to limit it off and when to run wild?

most times I want this limit, but sometimes the --all is good for scraping

georgettica commented 2 years ago

and once mentioned before, pd update doesn't work on npm install -g pagerduty-cli

martindstone commented 2 years ago

Oh yikes. That's a bug. Sorry, figuring it out now...

martindstone commented 2 years ago

I found the problem, ugh sorry, my logic for checking whether we fetched past the fetch limit was slightly wrong... i am pushing 0.1.2 now... wish there was a way to mark a version as "bad"

martindstone commented 2 years ago

Ok it's pushed. Can you try with 0.1.2 and let me know? Sorry for the screw up

georgettica commented 2 years ago

Sure, will do that tomorrow morning and let you know

georgettica commented 2 years ago

yup, works as expected. without --limit it shows all with --limit it shows what I wanted.

now for the next milestone we might allow --filter (count matching results)

martindstone commented 2 years ago

So I would really like to be able to do that but sadly everything in --filter happens after the data is fetched... that's why I disable it when --limit is given, because the results in this case could lead the user to believe things that are not true... and the filtering options that you can give to the REST API are very few... so the best way to try to filter and limit will be to pass --limit to rest:fetch and use other endpoint params as documented in the PD REST API doc to try and get what you want.

Regarding the update not working, I added the note about npm installs not being updatable more prominently to the doc. For anything more than that I will have to either change oclif/plugin-update or stop using it and make something myself which I think is longer term. I will continue to think about that... In the meantime i will plan to close this issue once i promote 0.1.2 to stable which should be in a few days...

Thanks!

georgettica commented 2 years ago

If this can also be noted inside the upgrade command itself that would be super nice

And if we are talking about upgrades, I see there is a new version available in the CLI, but you mentioned it's not stable and shouldn't be upgraded automatically

martindstone commented 2 years ago

Yeah i am going to promote 0.1.3 to stable soon, the most risky stuff in there is frankly what I did for this issue with the --limit flag; otherwise everything should be fine... the only changes from 0.1.2 to 0.1.3 are some added commands for working with tags...

martindstone commented 2 years ago

Closing this as fixed...