Managing 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
source-coop product list # public products
source-coop product list my-org --json # the products of one account, as JSON
source-coop product list --format table # one row for each product; tab-separated when piped
source-coop product list -q climate # search titles, descriptions and IDs
source-coop product list --tags zarr,climate --featured # featured products with all these tags
source-coop product list -L 100 # up to 100 (default 30, or all in the pager)
source-coop product list my-org -i # move through them full screen (see "Browsing with -i")
source-coop product view my-org/my-product # one product
source-coop product view my-org/my-product -w # open its page in the browser
source-coop product view my-org/my-product -i # its screen, with shortcuts; with no name, select one first
list has two formats:
--format details(default) shows the fields of each product, asviewdoes.--format tableshows one row for each product. On a terminal, the table is aligned and has a header. When piped, the rows are tab-separated, with no header.
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 --jsonlist -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
source-coop product create # asks for all values
source-coop product create my-org/my-product # asks for the other values
source-coop product create my-org/my-product -t "My product" -d "What's in it" \
--visibility public --data-connection my-connection
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:
- The accounts that you can create products in.
- A title made from the product ID.
- The data connections that the account can use.
- The visibilities that the selected data connection allows.
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 reviewEdit
source-coop product edit my-org/my-product # a form of its fields
source-coop product edit my-org/my-product --visibility unlisted
source-coop product edit my-org/my-product -d "New description" --json
source-coop product edit my-org/my-product --disable # --enable makes it active again (admins only)
source-coop product edit -i # select one of your account's products
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:
- ↑ ↓ moves between the fields.
- Enter changes the selected field, starting from its current value. Esc keeps the value.
- The form shows only the visibilities that the data connection allows.
- A changed field shows its old value.
- s, or Enter on Save changes, shows the changes and asks you to confirm. ← goes back to the form.
- Esc or ← on the form cancels. If you changed a field, the form asks first.
product edit: the edit form, then a flagDelete
source-coop product delete my-org/my-product # asks you to type the name
source-coop product delete my-org/my-product --preserve-data # keep its objects in storage
source-coop product delete my-org/my-product --yes --json # no questions, for scripts
source-coop product delete -i # select one of your account's products
delete asks two questions:
- Keep the product's data in storage?
--preserve-dataanswers yes. - 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