npm package: @snipplle/cli
Description: A CLI to manage Snipplle snippets
Author: Envial
Latest version: 1.0.0

@snipplle/cli
=================

Command-line tool to manage Snipplle snippets: authenticate, initialize projects, pull snippets and collections, and inspect versions — all from your terminal.


[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/@snipplle/cli.svg)](https://npmjs.org/package/@snipplle/cli)
[![Downloads/week](https://img.shields.io/npm/dw/@snipplle/cli.svg)](https://npmjs.org/package/@snipplle/cli)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
[![Node](https://img.shields.io/badge/node-%3E%3D18.0.0-339933)](https://nodejs.org/en/)


<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->

## Highlights

- Simple login with an API token and optional custom API URL.
- Project initialization with interactive prompts and multi-workspace support.
- Pull single snippets or entire collections to your project source directory.
- Inspect available versions for a snippet.
- Works with Node.js `>= 18` and uses familiar oclif ergonomics.

## Quick Start

1. Install globally:

   ```bash
   npm install -g @snipplle/cli
   # or: pnpm add -g @snipplle/cli
   # or: yarn global add @snipplle/cli
   ```

2. Login using your Snipplle API token:

   ```bash
   snipplle login <TOKEN>
   # optionally specify API URL (defaults to https://snipplle.com/api/cli)
   snipplle login <TOKEN> -u https://snipplle.com/api/cli
   ```

3. Initialize the current project (creates `snipplle.config.json`):

   ```bash
   snipplle init
   # You'll be asked for snippet source path (e.g. ./src/utils) and workspace slug.
   # You can also add additional workspace slugs.
   ```

4. Pull content:

   ```bash
   # Pull a collection
   snipplle pull -c <workspace_slug>/<collection_slug>

   # Pull a specific snippet by version tag
   snipplle pull -s <workspace_slug>/<snippet_slug>@<version_tag>
   ```

5. View snippet versions:

   ```bash
   snipplle version -s <workspace_slug>/<snippet_slug>
   ```

## Configuration

There are two configuration files used by the CLI:

- Global config at `~/.config/snipplle/config.json` (created on `login`):
  - `apiUrl`: Base API URL, defaults to `https://snipplle.com/api/cli`.
  - `token`: Your API token.
  - `userId`: Your Snipplle user ID.

- Project config at `./snipplle.config.json` (created on `init`):
  - `src`: Relative path where pulled files are saved (e.g. `./src/utils`).
  - `workspace.main`: `{ id, slug }` for the main workspace.
  - `workspace.additional`: Array of `{ id, slug }` for added workspaces.

Notes:

- If `snipplle.config.json` already exists, `init` will ask to overwrite.
- On `pull`, the CLI will create your `src` directory if it doesn’t exist.
- Filenames are derived from the snippet or collection path; the file extension is taken from the remote artifact URL.
# Usage
<!-- usage -->
```sh-session
$ npm install -g @snipplle/cli
$ snipplle COMMAND
running command...
$ snipplle (--version)
@snipplle/cli/1.0.0 darwin-arm64 node-v22.14.0
$ snipplle --help [COMMAND]
USAGE
  $ snipplle COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`snipplle help [COMMAND]`](#snipplle-help-command)
* [`snipplle init`](#snipplle-init)
* [`snipplle login TOKEN`](#snipplle-login-token)
* [`snipplle pull`](#snipplle-pull)
* [`snipplle version`](#snipplle-version)

## `snipplle help [COMMAND]`

Display help for snipplle.

```
USAGE
  $ snipplle help [COMMAND...] [-n]

ARGUMENTS
  [COMMAND...]  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for snipplle.
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.33/src/commands/help.ts)_

## `snipplle init`

Initialize Snipplle in the current project

```
USAGE
  $ snipplle init

DESCRIPTION
  Initialize Snipplle in the current project
```

_See code: [src/commands/init/index.ts](https://github.com/snipplle/snipplle-cli/blob/v1.0.0/src/commands/init/index.ts)_

## `snipplle login TOKEN`

Login to Snipplle

```
USAGE
  $ snipplle login TOKEN [-u <value>]

ARGUMENTS
  TOKEN  API token

FLAGS
  -u, --url=<value>  [default: https://studio.snipplle.com/api/cli] API URL

DESCRIPTION
  Login to Snipplle
```

_See code: [src/commands/login/index.ts](https://github.com/snipplle/snipplle-cli/blob/v1.0.0/src/commands/login/index.ts)_

## `snipplle pull`

Pull a snippet or a collection from Snipplle

```
USAGE
  $ snipplle pull [-c <value>] [-s <value>]

FLAGS
  -c, --collection=<value>  The collection to pull
  -s, --snippet=<value>     The snippet to pull

DESCRIPTION
  Pull a snippet or a collection from Snipplle

EXAMPLES
  $ snipplle pull -c workspace_slug/collection_slug

  $ snipplle pull -s workspace_slug/snippet_slug@version_tag
```

_See code: [src/commands/pull/index.ts](https://github.com/snipplle/snipplle-cli/blob/v1.0.0/src/commands/pull/index.ts)_

## `snipplle version`

Get the version of Snipplle

```
USAGE
  $ snipplle version [-s <value>]

FLAGS
  -s, --snippet=<value>  Get the versions of the snippet

DESCRIPTION
  Get the version of Snipplle
```

_See code: [src/commands/version/index.ts](https://github.com/snipplle/snipplle-cli/blob/v1.0.0/src/commands/version/index.ts)_
<!-- commandsstop -->

## Troubleshooting

- `You must specify a snippet or a collection`: Provide `-s` or `-c` flag to `pull`.
- `You don't have a project config`: Run `snipplle init` in your project first.
- `Snippet or collection file not found`: Check slugs and version tag correctness.
- API errors show `statusMessage`: Ensure your token is valid and you’re logged in.

## Contributing

- Issues: https://github.com/snipplle/snipplle-cli/issues
- Requirements: Node.js `>= 18`.
- Scripts:
  - `pnpm run build` — build TypeScript to `dist`.
  - `pnpm test` — run test suite.
  - `pnpm lint` — run ESLint.

Workflow:

- Fork the repo, create a feature branch, add tests if applicable, and open a PR.

## License

MIT © Snipplle

## Links

- Homepage: https://github.com/snipplle/snipplle-cli
- NPM: https://www.npmjs.com/package/@snipplle/cli