CLI guide
GitHub

Products

source-coop product lists, views, creates, edits and deletes products through the source.coop API (/api/v1). The CLI does not check values itself. It shows the API's errors for each field. A product's name is ACCOUNT/PRODUCT.

List and view

# public products
source-coop product list

# the products of one account, as JSON
source-coop product list my-org --json

# one row for each product; tab-separated when piped
source-coop product list --format table

# search titles, descriptions and IDs
source-coop product list -q climate

# featured products with all these tags
source-coop product list --tags zarr,climate --featured

# up to 100 (default 30, or all in the pager)
source-coop product list -L 100

# move through them full screen (see "Browsing with -i")
source-coop product list my-org -i

# one product
source-coop product view my-org/my-product

# open its page in the browser
source-coop product view my-org/my-product -w

# its screen, with shortcuts; with no name, select one first
source-coop product view my-org/my-product -i

list has two formats:

On a terminal, list shows the products in your pager and gets more pages as you read. In other cases, it stops at --limit. To continue from there, give --cursor the cursor that the last list printed.

product list: a table, a search, then --json

list -i and view -i show products full screen. Browsing with -i lists the keys.

product list -i: open a product, go back, filter with /

Create

# asks for all values
source-coop product create

# asks for the other values
source-coop product create my-org/my-product

# all values from flags
source-coop product create my-org/my-product -t "My product" -d "What's in it" \
    --visibility public --data-connection my-connection

# values from JSON on stdin
echo '{"title": "My product"}' | source-coop product create my-org/my-product -F -

Give the values as flags (--title, --description, --visibility, --data-connection), as a JSON object with --from-file PATH (- for stdin), or both. Flags take priority.

At a terminal, create asks for the missing values, with the web form's defaults:

You cannot change a product's data connection after you create it. For how to go back, the review, and drafts, see Prompts.

create prints the product's URL on stdout and its message on stderr. Thus url=$(source-coop product create ...) works.

product create with prompts: ↑ goes back a question, then the review

Edit

# a form of its fields
source-coop product edit my-org/my-product

# change one field
source-coop product edit my-org/my-product --visibility unlisted

# change one field and print the result as JSON
source-coop product edit my-org/my-product -d "New description" --json

# --enable makes it active again (admins only)
source-coop product edit my-org/my-product --disable

# select one of your account's products
source-coop product edit -i

edit uses the same values as create, but not the data connection. Give them as flags or with --from-file. --disable and --enable are flags only. edit prints the product's URL on stdout.

With no flags, edit opens a full-screen form of the title, description and visibility:

product edit: the edit form, then a flag

Delete

# asks you to type the name
source-coop product delete my-org/my-product

# keep its objects in storage
source-coop product delete my-org/my-product --preserve-data

# no questions, for scripts
source-coop product delete my-org/my-product --yes --json

# select one of your account's products
source-coop product delete -i

delete asks two questions:

  1. Keep the product's data in storage? --preserve-data answers yes.
  2. Type the product's name. If the text is different, nothing is deleted.

Without a terminal, delete needs --yes.

product delete: the name typed wrong, then right, then --yes