An open API service indexing awesome lists of open source software.

https://github.com/commercelayer/commercelayer-cli-plugin-resources


https://github.com/commercelayer/commercelayer-cli-plugin-resources

commercelayer

Last synced: about 1 year ago
JSON representation

Awesome Lists containing this project

README

          

# @commercelayer/cli-plugin-resources

Commerce Layer CLI Resources plugin

[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/@commercelayer/cli-plugin-resources.svg)](https://npmjs.org/package/@commercelayer/cli-plugin-resources)
[![Downloads/week](https://img.shields.io/npm/dw/@commercelayer/cli-plugin-resources.svg)](https://npmjs.org/package/@commercelayer/cli-plugin-resources)
[![License](https://img.shields.io/npm/l/@commercelayer/cli-plugin-resources.svg)](https://github.com/commercelayer/cli-plugin-resources/blob/master/package.json)
[![CodeQL](https://github.com/commercelayer/commercelayer-cli-plugin-resources/actions/workflows/codeql.yml/badge.svg)](https://github.com/commercelayer/commercelayer-cli-plugin-resources/actions/workflows/codeql.yml)

* [Usage](#usage)
* [Commands](#commands)

## Usage

```sh-session
commercelayer COMMAND

commercelayer [COMMAND] (--help | -h) for detailed information about plugin commands.
```

To install as a Commerce Layer CLI plugin run the following command:

```sh-session
$ commercelayer plugins:install resources
```

## Commands

* [`commercelayer resources`](#commercelayer-resources)
* [`commercelayer resources:all RESOURCE`](#commercelayer-resourcesall-resource)
* [`commercelayer resources:args`](#commercelayer-resourcesargs)
* [`commercelayer resources:count RESOURCE`](#commercelayer-resourcescount-resource)
* [`commercelayer resources:create RESOURCE`](#commercelayer-resourcescreate-resource)
* [`commercelayer resources:delete RESOURCE [ID]`](#commercelayer-resourcesdelete-resource-id)
* [`commercelayer resources:doc RESOURCE`](#commercelayer-resourcesdoc-resource)
* [`commercelayer resources:fetch PATH [ID]`](#commercelayer-resourcesfetch-path-id)
* [`commercelayer resources:filters`](#commercelayer-resourcesfilters)
* [`commercelayer resources:get RESOURCE [ID]`](#commercelayer-resourcesget-resource-id)
* [`commercelayer resources:history RESOURCE [ID]`](#commercelayer-resourceshistory-resource-id)
* [`commercelayer resources:last RESOURCE`](#commercelayer-resourceslast-resource)
* [`commercelayer resources:list RESOURCE`](#commercelayer-resourceslist-resource)
* [`commercelayer resources:retrieve RESOURCE [ID]`](#commercelayer-resourcesretrieve-resource-id)
* [`commercelayer resources:schema`](#commercelayer-resourcesschema)
* [`commercelayer resources:update RESOURCE [ID]`](#commercelayer-resourcesupdate-resource-id)

### `commercelayer resources`

List all the available Commerce Layer API resources.

```sh-session
USAGE
$ commercelayer resources [-h]

FLAGS
-h, --help Show CLI help.

DESCRIPTION
list all the available Commerce Layer API resources

EXAMPLES
$ cl-resources resources

$ cl-res resources

$ commercelayer resources

$ cl resources
```

_See code: [src/commands/resources/index.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/index.ts)_

### `commercelayer resources:all RESOURCE`

Fetch all resources.

```sh-session
USAGE
$ commercelayer resources:all RESOURCE [-i ...] [-u -j] [-l curl|node [--doc | -R]] [--curl ] [--node ]
[--save-args ] [--load-args ] [-w ...] [-s ...] [-x | -X ] [-D ,|;|||TAB
[-C -f ...]] [-H ... ] [-b] [-e ... | ]

ARGUMENTS
RESOURCE the resource type

FLAGS
-C, --csv export fields in csv format
-D, --delimiter= the delimiter character to use in the CSV output file (one of ',', ';', '|', TAB)

-H, --header=... rename column headers defining a comma-separated list of values field:"renamed title"
-R, --raw print out the raw API response
-X, --save-path= save command output to file and create missing path directories
-b, --blind execute in blind mode without prompt and progress bar
-e, --extract=... extract subfields from object attributes
-f, --fields=... comma separeted list of fields in the format [resourceType/]field1,field2,field3
-i, --include=... comma separated resources to include
-j, --json convert output in standard JSON format
-s, --sort=... define results ordering
-u, --unformatted print unformatted JSON output
-w, --where=... comma separated list of query filters
-x, --save= save command output to file
--load-args= load previously saved command arguments
--save-args= save command data to file for future use

DOCUMENTATION FLAGS
-l, --lang= show the CLI command in the specified language syntax

--curl show the equivalent cURL command of the CLI command
--doc show the CLI command in a specific language
--node show the equivalent Node SDK source code of the CLI command

DESCRIPTION
fetch all resources

ALIASES
$ commercelayer all
$ commercelayer ra
$ commercelayer res:all

EXAMPLES
$ commercelayer resources:all customers -f id,email,customer_group -i customer_group -s updated_at

$ cl res:all customers -i customer_group -f customer_group -f customer_groups/name -w customer_group_name_eq="GROUP NAME"

$ cl all customers -s -created_at --json
```

_See code: [src/commands/resources/all.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/all.ts)_

### `commercelayer resources:args`

Show all the saved command arguments.

```sh-session
USAGE
$ commercelayer resources:args [-D [-a -o list|retrieve|create|update -r ]]

FLAGS
-D, --delete delete saved arguments associated to the alias
-a, --alias= the alias associated to saved command arguments
-o, --operation= the resource operation

-r, --resource= the resource type

DESCRIPTION
show all the saved command arguments

ALIASES
$ commercelayer res:args
```

_See code: [src/commands/resources/args.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/args.ts)_

### `commercelayer resources:count RESOURCE`

Count the number of existent resources.

```sh-session
USAGE
$ commercelayer resources:count RESOURCE [-w ...]

ARGUMENTS
RESOURCE the resource type

FLAGS
-w, --where=... comma separated list of query filters

DESCRIPTION
count the number of existent resources

ALIASES
$ commercelayer count
$ commercelayer res:count
$ commercelayer rs:count

EXAMPLES
$ commercelayer resources:count customers

cl count customers -w customer_group_name_eq=
```

_See code: [src/commands/resources/count.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/count.ts)_

### `commercelayer resources:create RESOURCE`

Create a new resource.

```sh-session
USAGE
$ commercelayer resources:create RESOURCE [-i ...] [-f ...] [-u -j] [-l curl|node [--doc | -R]]
[--curl ] [--node ] [-H ] [-Y ] [-D | -a ... | -r ... | -m ... | | -O ... | -J
... | --load-args | --save-args ] [-t ...]

ARGUMENTS
RESOURCE the resource type

FLAGS
-D, --data= the data file to use as request body
-H, --headers show response headers
-J, --json-object=... define a resource object attribute in JSON format (value enclosed in single quotes)
-O, --object=... define a resource object attribute
-R, --raw print out the raw API response
-Y, --headers-only show only response headers
-a, --attribute=... define a resource attribute [name=value]
-f, --fields=... comma separeted list of fields in the format [resourceType/]field1,field2,field3
-i, --include=... comma separated resources to include
-j, --json convert output in standard JSON format
-m, --metadata=... define a metadata attribute or a set of metadata attributes
-r, --relationship=... define a relationship with another resource
-t, --tags=... list of tags associated with the resource
-u, --unformatted print unformatted JSON output
--load-args= load previously saved command arguments
--save-args= save command data to file for future use

DOCUMENTATION FLAGS
-l, --lang= show the CLI command in the specified language syntax

--curl show the equivalent cURL command of the CLI command
--doc show the CLI command in a specific language
--node show the equivalent Node SDK source code of the CLI command

DESCRIPTION
create a new resource

ALIASES
$ commercelayer create
$ commercelayer rc
$ commercelayer res:create
$ commercelayer post

EXAMPLES
$ commercelayer resources:create customers -a email=user@test.com

$ clayer res:create customers -a email="user@test-com" -r customer_group=customer_groups/

$ cl create customers -a email=user@test.com -m meta_key="meta value"

$ cl rc customers -D /path/to/data/file/data.json
```

_See code: [src/commands/resources/create.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/create.ts)_

### `commercelayer resources:delete RESOURCE [ID]`

Delete an existing resource.

```sh-session
USAGE
$ commercelayer resources:delete RESOURCE [ID] [-l curl|node [--doc | -R]] [--curl ] [--node ] [-H ] [-Y ]

ARGUMENTS
RESOURCE the resource type
ID id of the resources to delete (max 20)

FLAGS
-H, --headers show response headers
-R, --raw print out the raw API response
-Y, --headers-only show only response headers

DOCUMENTATION FLAGS
-l, --lang= show the CLI command in the specified language syntax

--curl show the equivalent cURL command of the CLI command
--doc show the CLI command in a specific language
--node show the equivalent Node SDK source code of the CLI command

DESCRIPTION
delete an existing resource

ALIASES
$ commercelayer delete
$ commercelayer rd
$ commercelayer res:delete

EXAMPLES
$ commercelayer resources:delete customers/

$ cl delete customers

$ cl rd customers ,,
```

_See code: [src/commands/resources/delete.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/delete.ts)_

### `commercelayer resources:doc RESOURCE`

Open the default browser and show the online documentation for the resource.

```sh-session
USAGE
$ commercelayer resources:doc RESOURCE [-p object|create|retrieve|list|update|delete]

ARGUMENTS
RESOURCE the resource for which you want to access the online documentation

FLAGS
-p, --page= the doc page you want to access

DESCRIPTION
open the default browser and show the online documentation for the resource

ALIASES
$ commercelayer res:doc
$ commercelayer doc

EXAMPLES
$ commercelayer resources:doc customers

$ cl res:doc customers

$ cl doc customers -p create
```

_See code: [src/commands/resources/doc.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/doc.ts)_

### `commercelayer resources:fetch PATH [ID]`

Retrieve a resource or list a set of resources.

```sh-session
USAGE
$ commercelayer resources:fetch PATH... [ID...] [-i ...] [-f ...] [-u -j] [-l curl|node [--doc | -R]]
[--curl ] [--node ] [--save-args ] [--load-args ] [-H ] [-Y ] [-x | -X ] [-e ...
| ] [-w ...] [-p ] [-n ] [-s ...]

ARGUMENTS
PATH... path (or URL) of the resource(s) to fetch
ID... resource id

FLAGS
-H, --headers show response headers
-R, --raw print out the raw API response
-X, --save-path= save command output to file and create missing path directories
-Y, --headers-only show only response headers
-e, --extract=... extract subfields from object attributes
-f, --fields=... comma separeted list of fields in the format [resourceType/]field1,field2,field3
-i, --include=... comma separated resources to include
-j, --json convert output in standard JSON format
-n, --pageSize= number of elements per page
-p, --page= page number
-s, --sort=... define results ordering
-u, --unformatted print unformatted JSON output
-w, --where=... comma separated list of query filters
-x, --save= save command output to file
--load-args= load previously saved command arguments
--save-args= save command data to file for future use

DOCUMENTATION FLAGS
-l, --lang= show the CLI command in the specified language syntax

--curl show the equivalent cURL command of the CLI command
--doc show the CLI command in a specific language
--node show the equivalent Node SDK source code of the CLI command

DESCRIPTION
retrieve a resource or list a set of resources

ALIASES
$ commercelayer fetch
$ commercelayer res:fetch
$ commercelayer rf

EXAMPLES
$ commercelayer resources:fetch customers

$ commercelayer res:fetch customers

$ clayer res:fetch customers/

$ cl fetch customers//

$ cl fetch customers/{customerId}/orders aBcdEkYWx
```

_See code: [src/commands/resources/fetch.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/fetch.ts)_

### `commercelayer resources:filters`

Show a list of all available filter predicates.

```sh-session
USAGE
$ commercelayer resources:filters

DESCRIPTION
show a list of all available filter predicates

ALIASES
$ commercelayer res:filters

EXAMPLES
$ commercelayer resources:filters

$ cl res:filters
```

_See code: [src/commands/resources/filters.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/filters.ts)_

### `commercelayer resources:get RESOURCE [ID]`

Retrieve a resource or list a set of resources.

```sh-session
USAGE
$ commercelayer resources:get RESOURCE... [ID...] [-i ...] [-f ...] [-u -j] [-l curl|node [--doc |
-R]] [--curl ] [--node ] [--save-args ] [--load-args ] [-H ] [-Y ] [-w ...] [-p ] [-n
] [-s ...] [-x | -X ] [-e ... | ]

ARGUMENTS
RESOURCE... the resource type
ID... id of the resource to retrieve

FLAGS
-H, --headers show response headers
-R, --raw print out the raw API response
-X, --save-path= save command output to file and create missing path directories
-Y, --headers-only show only response headers
-e, --extract=... extract subfields from object attributes
-f, --fields=... comma separeted list of fields in the format [resourceType/]field1,field2,field3
-i, --include=... comma separated resources to include
-j, --json convert output in standard JSON format
-n, --pageSize= number of elements per page
-p, --page= page number
-s, --sort=... define results ordering
-u, --unformatted print unformatted JSON output
-w, --where=... comma separated list of query filters
-x, --save= save command output to file
--load-args= load previously saved command arguments
--save-args= save command data to file for future use

DOCUMENTATION FLAGS
-l, --lang= show the CLI command in the specified language syntax

--curl show the equivalent cURL command of the CLI command
--doc show the CLI command in a specific language
--node show the equivalent Node SDK source code of the CLI command

DESCRIPTION
retrieve a resource or list a set of resources

ALIASES
$ commercelayer get
$ commercelayer res:get
$ commercelayer rg

EXAMPLES
$ commercelayer resources:get customers

$ commercelayer res:get customers

$ clayer res:get customers/

$ cl get customers
```

_See code: [src/commands/resources/get.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/get.ts)_

### `commercelayer resources:history RESOURCE [ID]`

Show history of a resource.

```sh-session
USAGE
$ commercelayer resources:history RESOURCE [ID]

ARGUMENTS
RESOURCE the resource type
ID id of the resource to retrieve

DESCRIPTION
show history of a resource

ALIASES
$ commercelayer versions
$ commercelayer history
$ commercelayer rh
$ commercelayer res:history

EXAMPLES
$ commercelayer resources:history customers/

$ commercelayer history customers

$ cl res:hidtory customers

$ clayer rh customers/
```

_See code: [src/commands/resources/history.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/history.ts)_

### `commercelayer resources:last RESOURCE`

Show the last id of a resource type.

```sh-session
USAGE
$ commercelayer resources:last RESOURCE

ARGUMENTS
RESOURCE the resource type

DESCRIPTION
show the last id of a resource type

ALIASES
$ commercelayer last
$ commercelayer res:last

EXAMPLES
$ commercelayer resources:last customers

$ commercelayer last customer

$ cl res:last customers
```

_See code: [src/commands/resources/last.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/last.ts)_

### `commercelayer resources:list RESOURCE`

Fetch a collection of resources.

```sh-session
USAGE
$ commercelayer resources:list RESOURCE [-i ...] [-f ...] [-u -j] [-l curl|node [--doc | -R]]
[--curl ] [--node ] [--save-args ] [--load-args ] [-H ] [-Y ] [-w ...] [-p ] [-n
] [-s ...] [-x | -X ] [-e ... | ]

ARGUMENTS
RESOURCE the resource type

FLAGS
-H, --headers show response headers
-R, --raw print out the raw API response
-X, --save-path= save command output to file and create missing path directories
-Y, --headers-only show only response headers
-e, --extract=... extract subfields from object attributes
-f, --fields=... comma separeted list of fields in the format [resourceType/]field1,field2,field3
-i, --include=... comma separated resources to include
-j, --json convert output in standard JSON format
-n, --pageSize= number of elements per page
-p, --page= page number
-s, --sort=... define results ordering
-u, --unformatted print unformatted JSON output
-w, --where=... comma separated list of query filters
-x, --save= save command output to file
--load-args= load previously saved command arguments
--save-args= save command data to file for future use

DOCUMENTATION FLAGS
-l, --lang= show the CLI command in the specified language syntax

--curl show the equivalent cURL command of the CLI command
--doc show the CLI command in a specific language
--node show the equivalent Node SDK source code of the CLI command

DESCRIPTION
fetch a collection of resources

ALIASES
$ commercelayer list
$ commercelayer rl
$ commercelayer res:list

EXAMPLES
$ commercelayer resources:list customers -f id,email,customer_group -i customer_group -s updated_at

$ cl res:list customers -i customer_group -f customer_group -f customer_groups/name -w customer_group_name_eq="GROUP NAME"

$ cl list customers -p 5 -n 10 -s -created_at --raw
```

_See code: [src/commands/resources/list.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/list.ts)_

### `commercelayer resources:retrieve RESOURCE [ID]`

Fetch a single resource.

```sh-session
USAGE
$ commercelayer resources:retrieve RESOURCE [ID] [-i ...] [-f ...] [-u -j] [-l curl|node [--doc | -R]]
[--curl ] [--node ] [--save-args ] [--load-args ] [-H ] [-Y ] [-x | -X ] [-e ...
| ]

ARGUMENTS
RESOURCE the resource type
ID id of the resource to retrieve

FLAGS
-H, --headers show response headers
-R, --raw print out the raw API response
-X, --save-path= save command output to file and create missing path directories
-Y, --headers-only show only response headers
-e, --extract=... extract subfields from object attributes
-f, --fields=... comma separeted list of fields in the format [resourceType/]field1,field2,field3
-i, --include=... comma separated resources to include
-j, --json convert output in standard JSON format
-u, --unformatted print unformatted JSON output
-x, --save= save command output to file
--load-args= load previously saved command arguments
--save-args= save command data to file for future use

DOCUMENTATION FLAGS
-l, --lang= show the CLI command in the specified language syntax

--curl show the equivalent cURL command of the CLI command
--doc show the CLI command in a specific language
--node show the equivalent Node SDK source code of the CLI command

DESCRIPTION
fetch a single resource

ALIASES
$ commercelayer retrieve
$ commercelayer rr
$ commercelayer res:retrieve

EXAMPLES
$ commercelayer resources:retrieve customers/

$ commercelayer retrieve customers

$ cl res:retrieve customers

$ clayer rr customers/
```

_See code: [src/commands/resources/retrieve.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/retrieve.ts)_

### `commercelayer resources:schema`

Show the current CommerceLayer OpenAPI schema version used by the plugin.

```sh-session
USAGE
$ commercelayer resources:schema

DESCRIPTION
show the current CommerceLayer OpenAPI schema version used by the plugin

ALIASES
$ commercelayer schema
$ commercelayer res:schema
$ commercelayer rs

EXAMPLES
$ commercelayer schema

cl res:schema
```

_See code: [src/commands/resources/schema.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/schema.ts)_

### `commercelayer resources:update RESOURCE [ID]`

Update an existing resource.

```sh-session
USAGE
$ commercelayer resources:update RESOURCE [ID] [-i ...] [-f ...] [-u -j] [-l curl|node [--doc | -R]]
[--curl ] [--node ] [-H ] [-Y ] [-D | -a ... | -r ... | [-m ... | -M ...] | |
| -O ... | -J ... | --load-args | --save-args ] [-t ...]

ARGUMENTS
RESOURCE the resource type
ID id of the resource to update

FLAGS
-D, --data= the data file to use as request body
-H, --headers show response headers
-J, --json-object=... define a resource object attribute in JSON format (value enclosed in single quotes)
-M, --metadata-replace=... define a metadata attribute and replace every item already present in the remote
resource
-O, --object=... define a resource object attribute
-R, --raw print out the raw API response
-Y, --headers-only show only response headers
-a, --attribute=... define a resource attribute
-f, --fields=... comma separeted list of fields in the format [resourceType/]field1,field2,field3
-i, --include=... comma separated resources to include
-j, --json convert output in standard JSON format
-m, --metadata=... define a metadata attribute and merge it with the metadata already present in the
remote resource
-r, --relationship=... define a relationship with another resource
-t, --tags=... list of tags associated with the resource
-u, --unformatted print unformatted JSON output
--load-args= load previously saved command arguments
--save-args= save command data to file for future use

DOCUMENTATION FLAGS
-l, --lang= show the CLI command in the specified language syntax

--curl show the equivalent cURL command of the CLI command
--doc show the CLI command in a specific language
--node show the equivalent Node SDK source code of the CLI command

DESCRIPTION
update an existing resource

ALIASES
$ commercelayer update
$ commercelayer ru
$ commercelayer res:update
$ commercelayer patch

EXAMPLES
$ commercelayer resources:update customers/ -a reference=referenceId

$ commercelayer res:update customers -a reference_origin="Ref Origin"

$ cl update customers/ -m meta_key="meta value"

$ cl ru customers -M meta_key="metadata overwrite

$ clayer update customers -D /path/to/data/file/data.json

$ cl update order -r billing_address=addresses/

$ cl update customer -r customer_group=
```

_See code: [src/commands/resources/update.ts](https://github.com/commercelayer/commercelayer-cli-plugin-resources/blob/main/src/commands/resources/update.ts)_