planet-client-python icon indicating copy to clipboard operation
planet-client-python copied to clipboard

Added --ids-only option

Open kevinlacaille opened this issue 2 years ago • 2 comments

Related Issue(s):

Closes #645

Proposed Changes:

For inclusion in changelog (if applicable):

  1. Added a flag, ids-only, which returns only the item IDs from a search or order, to the following functions: data search, data search-run, orders get

Not intended for changelog:

Diff of User Interface

Old behavior:

❯ planet <command>  | jq -r .id | tr '\n' ',' | sed 's/.$//'
Comma separate list of item ids

For example, data search

❯ planet data search psscene --limit 10 | jq -r .id | tr '\n' ',' | sed 's/.$//'                      
20230427_104445_51_248b,20230427_072107_90_242e,20230427_071646_44_248c,20230303_161806_29_24bb,20230303_161803_87_24bb,20230427_104441_19_248b,20230427_104126_76_248b,20230427_103940_90_248b,20230427_100416_94_249a,20230427_082511_30_24bc%                                                                                    

New behavior:

❯ planet <command>  --ids-only
Comma separate list of item ids

data search

❯ planet data search psscene --limit 10 --ids-only                                                      
20230426_065727_44_2479,20230426_171106_48_2423,20230426_174958_25_24b9,20230426_170845_64_2423,20230426_170834_96_2423,20230426_165943_74_2416,20230426_161130_11_24b5,20230426_161044_90_24b5,20230426_092428_35_2432,20230426_085011_34_2465

data search-run

❯ planet data search-run 42b0e1ff085d4a57a34236d36674703e --limit 10 --ids-only   
20230427_072359_07_2458,20230427_072754_74_242b,20230427_061032_97_2473,20230427_071806_81_242b,20230427_052015_19_2446,20230426_140020_91_2276,20230426_135909_86_2276,20230427_025450_23_2415,20230427_072850_11_242b,20230427_070835_13_24af

orders get

❯ planet orders get 38d89352-e90a-4cd7-9964-dfe629d5081b --ids-only
20230409_100344_03_2484,20230409_100341_88_2484,20230409_101856_12_2414,20230409_101854_08_2414,20230406_100337_05_2488

PR Checklist:

  • [x] This PR is as small and focused as possible
  • [x] If this PR includes proposed changes for inclusion in the changelog, the title of this PR summarizes those changes and is ready for inclusion in the Changelog.
  • [] I have updated docstrings for function changes and docs in the 'docs' folder for user interface / behavior changes
  • [] This PR does not break any examples or I have updated them

(Optional) @mentions for Notifications:

kevinlacaille avatar Apr 26 '23 20:04 kevinlacaille

I realized I never explained this in the original ticket, but the key for this is that the output can be directly piped into the orders request command. So it needs to remove the " and replace the newlines with commas. So output should be like 20230120_003217_79_24ab,20230120_003215_49_24ab,20230120_003213_19_24ab,20230120_003210_89_24ab,20230128_003142_04_24ab

cholmes avatar Apr 26 '23 21:04 cholmes

I am against merging this at this time. Lets have more discussion.

jreiberkyle avatar May 04 '23 18:05 jreiberkyle