-
Notifications
You must be signed in to change notification settings - Fork 95
CLI tutorials #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
CLI tutorials #642
Changes from 25 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
a353d3a
first crack at commands
cholmes 8e81085
Revert "first crack at commands"
cholmes 742434a
first crack at commands
cholmes f69775f
more examples
cholmes 1ea9408
first commit, mostly placeholder
cholmes 28dcb77
more additions
cholmes b62b0b5
another thing to add
cholmes 5ce0a71
Merge branch 'main' into cli-tutorial
cholmes 4bbb895
Merge branch 'main' into cli-tutorial
cholmes 8a291c4
more improvements
cholmes 8aaea27
initial commit of more advanced tutorial stuff
cholmes 4650354
minor changes
cholmes 828f19f
added a nice way to not copy/paste order ids
cholmes d9dc58f
Merge branch 'main' into cli-tutorial
cholmes fe2b23f
more updates
cholmes 18e49ca
improvements
cholmes eb63965
finishing off the first pass
cholmes 4696700
more improvements
cholmes 5e5a524
more kepler info
cholmes b998300
small fixes
cholmes 518130e
more improvements
cholmes 087770b
changed quick-search to search, updates
cholmes 302ab93
added warning messages, more info
cholmes 0e02559
added note to add centroid with gdal
cholmes 11865a6
Merge branch 'main' into cli-tutorial
cholmes 50916aa
Update docs/cli-concepts.md
cholmes db90a03
Update docs/cli-tutorial.md
cholmes 7839a5b
Update docs/cli-concepts.md
cholmes a2d97ae
Update docs/cli-plus-tutorial.md
cholmes fef2254
added to ToC, improvements
cholmes ba11ed2
added request geojson to be in this repo
cholmes 444e4e2
added clip-composite request
cholmes 14459a4
update paths
cholmes 3c0bbbb
moved to data directory
cholmes dcdc4c6
Merge branch 'main' into cli-tutorial
cholmes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Command-line Interface (CLI) Concepts | ||
|
||
Planet's command-line interface is built of composable pieces that combine in powerful ways. | ||
To take full advantage of all that Planet's CLI offers there are a few concepts and tools | ||
that are worth explaining. | ||
|
||
**NOTE:** This document is still a work in progress, but we'll work to flesh it out. We'll | ||
leave it up since there's still a bit of good information. | ||
|
||
## Core Unix Concepts | ||
|
||
If you are completely new to the command-line we recommend starting with a real introductory | ||
guide like (TODO, link to a good guide). But we wanted to go over a few key concepts that | ||
are a bit more 'advanced', as they allow you to get the most out of Planet's CLI. These are | ||
all built into any unix command-line, including Linux and the Mac terminal. If you're on | ||
Windows you can use [Windows Subsytem for Linux](https://docs.microsoft.com/en-us/windows/wsl/about) | ||
or [Cygwin](https://www.cygwin.com/). | ||
|
||
### Piping & Redirection | ||
|
||
Several commands in the Planet CLI are used to create files that are used as input to | ||
other commands. The default of these commands is to just print the output on your screen. | ||
Seeing it on the screen can be useful for making sure it's right, but you'll most likely | ||
want to make use of it. This is where the concept of 'redirection' in. If you use the | ||
`>` character and then specify a file name the command-line will save its output to that file. | ||
So if you say: | ||
|
||
``` | ||
$ planet data filter --range cloud_percent lt 10 > filter.json | ||
cholmes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
Then the output will be saved. This output is referred to as STDOUT, or 'standard output'. | ||
There is much more in this vein that you can do, like use `>>` to append to an existing | ||
file, or `<` to send what's in the file as input for a command. | ||
|
||
One of the most powerful concepts that we use extensively in the Planet CLI is 'piping'. | ||
The `|` is the pipe symbol, and it's a special command that lets you pass the output from | ||
one command to be the input for the next one. So instead of having to save to a file and | ||
then referring to it you can just do it all in one call: | ||
|
||
``` | ||
planet data filter --range cloud_percent lt 10 | planet data search-quick PSScene - | ||
``` | ||
|
||
The pipe says to take the output of the first command and pass it to the input of | ||
the second. You'll notice that the planet command has a dash (`-`), this is a convention | ||
that is often used by different CLI programs to explicitly say 'read from | ||
standard out'. Most Planet CLI commands require it, but one or two will implicitly | ||
read from standard out if it's not explicitly included. Using the dash to mean | ||
'read from standard out' is a general convention used by many programs, but it's | ||
not universal, so check the docs of the program you're using as to how it reads | ||
from piped input. For example GDAL/OGR uses a specific `/vsistdin/` convention to | ||
read from a pipe. | ||
|
||
If you'd like to learn more about these topics then check out | ||
[this tutorial](https://ryanstutorials.net/linuxtutorial/piping.php). And if you'd | ||
like to learn more about the dash (`-`) see | ||
[this tutorial](https://www.baeldung.com/linux/dash-in-command-line-parameters). | ||
|
||
|
||
### head & tail | ||
|
||
Also less/more? | ||
|
||
### Running a command within another | ||
|
||
### variables | ||
|
||
## JQ | ||
|
||
## curl | ||
|
||
## sed | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.