# CLI

> Shelve CLI is a command-line interface designed for the Shelve app.

The CLI serves as a command-line interface designed for the [Shelve app](https://dub.sh/shelve). Facilitating the seamless transfer of environment variables for project collaboration within a team directly through the terminal interface, but way more other features are and will be available !

## Installation

To install the CLI, please refer to the [Quickstart](/docs/getting-started/quickstart) guide.

## Configuration

Configuration is loaded from cwd. You can use either shelve.json, shelve.config.json or .shelverc.json, but running the CLI without any configuration will create a shelve.json file.

The CLI also has a json schema for the configuration file. that can be used to validate the configuration file [(see it here)](https://raw.githubusercontent.com/HugoRCD/shelve/main/packages/types/schema.json).

```json [shelve.json]
{
  "slug": "nuxtlabs",
  "project": "@nuxt/ui",
  "confirmChanges": true,
  "autoCreateProject": true
}
```

### Monorepo support

Shelve natively supports monorepos, tf you are using a monorepo, Shelve will automatically detect the root of the monorepo and look for the global `shelve.json` file. You can define here common configurations for all the projects in the monorepo (the team `slug` for example):

<code-tree default-value="shelve.json">

```json [apps/app/shelve.json]
{
  "project": "@nuxt/app",
  "confirmChanges": true
}
```

```json [apps/app/package.json]
{
  "name": "@nuxt/app"
}
```

```json [apps/api/shelve.json]
{
  "project": "@nuxt/api",
  "envFileName": ".env.development"
}
```

```json [apps/api/package.json]
{
  "name": "@nuxt/api"
}
```

```json [packages/cli/shelve.json]
{
  "project": "@nuxt/cli"
}
```

```json [packages/cli/package.json]
{
  "name": "@nuxt/cli"
}
```

```json [shelve.json]
{
  "slug": "nuxtlabs"
}
```

```json [package.json]
{
  "name": "nuxtlabs"
}
```

</code-tree>

### Monorepo usage

If you are using a monorepo, running a command at the root level will execute the command for all the projects in the monorepo that have a `shelve.json` file.

Example:

```bash [terminal]
shelve pull
```

This command will execute the `pull` command for all the projects in the monorepo that have a `shelve.json` file.

```bash [apps/app/terminal]
shelve pull
```

This command will execute the `pull` command for the `@nuxt/app` project.

## Options

Here are all the available options for the configuration file:

<table>
<thead>
  <tr>
    <th>
      Option
    </th>
    
    <th>
      Type
    </th>
    
    <th>
      Default
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        project
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        process.env.SHELVE_PROJECT
      </code>
      
       or nearest package.json name
    </td>
    
    <td>
      The name of your project
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        slug
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        process.env.SHELVE_TEAM_SLUG
      </code>
    </td>
    
    <td>
      Your team slug (can be found in your team settings)
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        token
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      OS keychain (preferred) or <code>
        $XDG_CONFIG_HOME/.shelve
      </code>
      
       after <code>
        shelve login
      </code>
      
      , or <code>
        process.env.SHELVE_TOKEN
      </code>
    </td>
    
    <td>
      Authentication token created via app.shelve.cloud/user/tokens
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        url
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        https://app.shelve.cloud
      </code>
    </td>
    
    <td>
      URL of the Shelve instance
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        defaultEnv
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      
    </td>
    
    <td>
      The default environment use by the command like <code>
        run
      </code>
      
      , <code>
        push
      </code>
      
       or <code>
        pull
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        confirmChanges
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        false
      </code>
    </td>
    
    <td>
      Whether to confirm changes before applying them
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        envFileName
      </code>
    </td>
    
    <td>
      <code>
        string
      </code>
    </td>
    
    <td>
      <code>
        .env
      </code>
    </td>
    
    <td>
      Name of your environment file
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        autoUppercase
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Automatically uppercase environment variable keys
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        autoCreateProject
      </code>
    </td>
    
    <td>
      <code>
        boolean
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
    </td>
    
    <td>
      Automatically create project if it doesn't exist
    </td>
  </tr>
</tbody>
</table>

## Environment Variables

The following environment variables can be used to override configuration options:

<table>
<thead>
  <tr>
    <th>
      Variable
    </th>
    
    <th>
      Description
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        SHELVE_PROJECT
      </code>
    </td>
    
    <td>
      Project name
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SHELVE_TEAM_SLUG
      </code>
    </td>
    
    <td>
      Team slug
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SHELVE_TOKEN
      </code>
    </td>
    
    <td>
      Authentication token
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SHELVE_URL
      </code>
    </td>
    
    <td>
      Shelve instance URL
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SHELVE_DEFAULT_ENV
      </code>
    </td>
    
    <td>
      Default env for CLI command
    </td>
  </tr>
</tbody>
</table>
