npm package: @sanity/views-cli
Description: Sanity's CLI for Views
Author: Sanity Content Lake Team
Latest version: 0.5.0

@sanity/views-cli
===================

Sanity's CLI for Views


[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/@sanity/views-cli.svg)](https://npmjs.org/package/@sanity/views-cli)
[![Downloads/week](https://img.shields.io/npm/dw/@sanity/views-cli.svg)](https://npmjs.org/package/@sanity/views-cli)


<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->
# Usage
<!-- usage -->
```sh-session
$ npm install -g @sanity/views-cli
$ views-cli COMMAND
running command...
$ views-cli (--version)
@sanity/views-cli/0.5.0 linux-x64 node-v22.16.0
$ views-cli --help [COMMAND]
USAGE
  $ views-cli COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`views-cli view connection create CONNECTIONNAME`](#views-cli-view-connection-create-connectionname)
* [`views-cli view connection delete CONNECTIONNAME`](#views-cli-view-connection-delete-connectionname)
* [`views-cli view connection list VIEW_NAME`](#views-cli-view-connection-list-view_name)
* [`views-cli view connection update CONNECTIONNAME`](#views-cli-view-connection-update-connectionname)
* [`views-cli view connection watch CONNECTIONNAME`](#views-cli-view-connection-watch-connectionname)
* [`views-cli view create NAME`](#views-cli-view-create-name)
* [`views-cli view delete NAME`](#views-cli-view-delete-name)
* [`views-cli view list`](#views-cli-view-list)
* [`views-cli view update CURRENT_NAME NEW_NAME`](#views-cli-view-update-current_name-new_name)
* [`views-cli view watch VIEWNAME`](#views-cli-view-watch-viewname)

## `views-cli view connection create CONNECTIONNAME`

Create a connection on your view.

```
USAGE
  $ views-cli view connection create CONNECTIONNAME -o <value> -v <value> -p <value> -d <value> -a <value> [-f] [-q <value>]
    [-f <value>]

ARGUMENTS
  CONNECTIONNAME  Name of the connection to create

FLAGS
  -a, --apiVersion=<value>  (required) api version to use for the query
  -d, --dataset=<value>     (required) dataset to materialise to the view
  -f, --file=<value>        file containing a query to run
  -f, --force               bypass creation warnings
  -p, --project=<value>     (required) project id to materialise to the view
  -q, --query=<value>       query to run
  -v, --view=<value>        (required) name of the view to create connection on

GLOBAL FLAGS
  -o, --organizationId=<value>  (required) organization id to query. This can also be set as an environment variable
                                `SANITY_ORGANIZATION_ID`.

DESCRIPTION
  Create a connection on your view.

EXAMPLES
  $ views-cli view connection create connection-name --organizationId=org-id --apiVersion=2021-06-07 --dataset=dataset-name --project=project-id --view=view-name --query="*"

  $ views-cli view connection create connection-name --organizationId=org-id --apiVersion=2021-06-07 --dataset=dataset-name --project=project-id --view=view-name --file=~/path/to/query.groq

  $ SANITY_ORGANIZATION_ID=org-id views-cli view connection create …others args and flags
```

_See code: [src/commands/view/connection/create.ts](https://github.com/sanity-io/views-cli/blob/v0.5.0/src/commands/view/connection/create.ts)_

## `views-cli view connection delete CONNECTIONNAME`

Delete a connection from a view.

```
USAGE
  $ views-cli view connection delete CONNECTIONNAME -o <value> -v <value>

ARGUMENTS
  CONNECTIONNAME  Name of the connection to delete

FLAGS
  -v, --view=<value>  (required) name of the view the connection exists on

GLOBAL FLAGS
  -o, --organizationId=<value>  (required) organization id to query. This can also be set as an environment variable
                                `SANITY_ORGANIZATION_ID`.

DESCRIPTION
  Delete a connection from a view.

EXAMPLES
  $ views-cli view connection delete my-connection --view=my-view --organizationId=org-id

  SANITY_ORGANIZATION_ID=org-id views-cli view connection delete my-connection --view=my-view
```

_See code: [src/commands/view/connection/delete.ts](https://github.com/sanity-io/views-cli/blob/v0.5.0/src/commands/view/connection/delete.ts)_

## `views-cli view connection list VIEW_NAME`

List the connections configured for a view connection.

```
USAGE
  $ views-cli view connection list VIEW_NAME -o <value>

ARGUMENTS
  VIEW_NAME  view to list connections for

GLOBAL FLAGS
  -o, --organizationId=<value>  (required) organization id to query. This can also be set as an environment variable
                                `SANITY_ORGANIZATION_ID`.

DESCRIPTION
  List the connections configured for a view connection.

EXAMPLES
  $ views-cli view connection list my-view --organizationId=org-id

  SANITY_ORGANIZATION_ID=org-id views-cli view connection list my-view
```

_See code: [src/commands/view/connection/list.ts](https://github.com/sanity-io/views-cli/blob/v0.5.0/src/commands/view/connection/list.ts)_

## `views-cli view connection update CONNECTIONNAME`

Update a connection.

```
USAGE
  $ views-cli view connection update CONNECTIONNAME -o <value> -v <value> [-a <value>] [-n <value>] [-q <value>] [-f
  <value>]

ARGUMENTS
  CONNECTIONNAME  Name of the connection to update

FLAGS
  -a, --apiVersion=<value>  api version to use for the query
  -f, --file=<value>        file containing a query to run
  -n, --newName=<value>     new name for the connection
  -q, --query=<value>       query to run
  -v, --view=<value>        (required) name of the view the connection exists on

GLOBAL FLAGS
  -o, --organizationId=<value>  (required) organization id to query. This can also be set as an environment variable
                                `SANITY_ORGANIZATION_ID`.

DESCRIPTION
  Update a connection.

EXAMPLES
  $ views-cli view connection update connection-name --organizationId=org-id --apiVersion=2021-06-07 --newName=new-connection-name --view=view-name --query="*"

  $ views-cli view connection update connection-name --organizationId=org-id --apiVersion=2021-06-07 --newName=new-connection-name --view=view-name --file=~/path/to/query.groq

  $ SANITY_ORGANIZATION_ID=org-id views-cli view connection update …others args and flags
```

_See code: [src/commands/view/connection/update.ts](https://github.com/sanity-io/views-cli/blob/v0.5.0/src/commands/view/connection/update.ts)_

## `views-cli view connection watch CONNECTIONNAME`

Watch real-time logging events for a view connection.

```
USAGE
  $ views-cli view connection watch CONNECTIONNAME -o <value> -v <value> [-r] [--no-color] [--errors-only]

ARGUMENTS
  CONNECTIONNAME  Name of the connection to watch

FLAGS
  -r, --replay        replay events from the last hour, along with live events
  -v, --view=<value>  (required) name of the view the connection exists on
      --errors-only   only show error events
      --no-color      disable colored output

GLOBAL FLAGS
  -o, --organizationId=<value>  (required) organization id to query. This can also be set as an environment variable
                                `SANITY_ORGANIZATION_ID`.

DESCRIPTION
  Watch real-time logging events for a view connection.

EXAMPLES
  $ views-cli view connection watch connection-name --view=my-view --organizationId=org-id

  $ views-cli view connection watch connection-name --view=my-view --replay --organizationId=org-id

  SANITY_ORGANIZATION_ID=org-id views-cli view connection watch connection-name --view=my-view
```

_See code: [src/commands/view/connection/watch.ts](https://github.com/sanity-io/views-cli/blob/v0.5.0/src/commands/view/connection/watch.ts)_

## `views-cli view create NAME`

Create a new view.

```
USAGE
  $ views-cli view create NAME -o <value> [-m public|private]

FLAGS
  -m, --aclMode=<option>  [default: public] ACL mode to use for the View
                          <options: public|private>

GLOBAL FLAGS
  -o, --organizationId=<value>  (required) organization id to query. This can also be set as an environment variable
                                `SANITY_ORGANIZATION_ID`.

DESCRIPTION
  Create a new view.

EXAMPLES
  $ views-cli view create my-view --organizationId=org-id

  SANITY_ORGANIZATION_ID=org-id views-cli view create my-view
```

_See code: [src/commands/view/create.ts](https://github.com/sanity-io/views-cli/blob/v0.5.0/src/commands/view/create.ts)_

## `views-cli view delete NAME`

Delete view.

```
USAGE
  $ views-cli view delete NAME -o <value>

GLOBAL FLAGS
  -o, --organizationId=<value>  (required) organization id to query. This can also be set as an environment variable
                                `SANITY_ORGANIZATION_ID`.

DESCRIPTION
  Delete view.

EXAMPLES
  $ views-cli view delete my-view --organizationId=org-id

  SANITY_ORGANIZATION_ID=org-id views-cli view delete my-view
```

_See code: [src/commands/view/delete.ts](https://github.com/sanity-io/views-cli/blob/v0.5.0/src/commands/view/delete.ts)_

## `views-cli view list`

List the Views in your Organization

```
USAGE
  $ views-cli view list -o <value>

GLOBAL FLAGS
  -o, --organizationId=<value>  (required) organization id to query. This can also be set as an environment variable
                                `SANITY_ORGANIZATION_ID`.

DESCRIPTION
  List the Views in your Organization

EXAMPLES
  $ views-cli view list --organizationId=org-id

  SANITY_ORGANIZATION_ID=org-id views-cli view list
```

_See code: [src/commands/view/list.ts](https://github.com/sanity-io/views-cli/blob/v0.5.0/src/commands/view/list.ts)_

## `views-cli view update CURRENT_NAME NEW_NAME`

Updates the view name.

```
USAGE
  $ views-cli view update CURRENT_NAME NEW_NAME -o <value>

ARGUMENTS
  CURRENT_NAME  Name of the view to update
  NEW_NAME      New name for the view.

GLOBAL FLAGS
  -o, --organizationId=<value>  (required) organization id to query. This can also be set as an environment variable
                                `SANITY_ORGANIZATION_ID`.

DESCRIPTION
  Updates the view name.

EXAMPLES
  $ views-cli view update CURRENT_NAME NEW_NAME --organizationId=org-id

  SANITY_ORGANIZATION_ID=org-id views-cli view update CURRENT_NAME NEW_NAME
```

_See code: [src/commands/view/update.ts](https://github.com/sanity-io/views-cli/blob/v0.5.0/src/commands/view/update.ts)_

## `views-cli view watch VIEWNAME`

Watch real-time logging events for all connections in a view.

```
USAGE
  $ views-cli view watch VIEWNAME -o <value> [-r] [--no-color] [--errors-only]

ARGUMENTS
  VIEWNAME  Name of the view to watch

FLAGS
  -r, --replay       replay events from the last hour, along with live events
      --errors-only  only show error events
      --no-color     disable colored output

GLOBAL FLAGS
  -o, --organizationId=<value>  (required) organization id to query. This can also be set as an environment variable
                                `SANITY_ORGANIZATION_ID`.

DESCRIPTION
  Watch real-time logging events for all connections in a view.

EXAMPLES
  $ views-cli view watch my-view --organizationId=org-id

  $ views-cli view watch my-view --replay --organizationId=org-id

  SANITY_ORGANIZATION_ID=org-id views-cli view watch my-view
```

_See code: [src/commands/view/watch.ts](https://github.com/sanity-io/views-cli/blob/v0.5.0/src/commands/view/watch.ts)_
<!-- commandsstop -->