open-index/open-npm huggingface dataset:
npm package: @od-canvas/cli
Description: Canvas CLI for managing content and projects
Latest version: 1.0.0

# Canvas CLI

A command-line interface for managing Canvas CMS content and projects.

## Installation

```bash
npm install -g @canvas/cli
```

Or use with `npx`:

```bash
npx @canvas/cli projects list
```

## Configuration

Set the following environment variables in your `.env` file or shell:

```bash
CANVAS_API_URL=http://localhost:8080/api
CANVAS_API_KEY=your_api_key_here
```

You can also create a `.env` file in your project directory and the CLI will automatically load it.

## Commands

### Projects

Manage Canvas projects.

#### List all projects
```bash
canvas projects list
```

Shows all projects you own with document counts and creation dates.

#### Create a new project
```bash
canvas projects create "My Blog"
```

Creates a new project and returns the project ID.

#### Get project details
```bash
canvas projects get 1
```

Shows detailed information about a specific project.

### Documents

Manage documents within a project.

#### List documents in a project
```bash
canvas docs list 1
```

Lists all documents in project ID 1, showing:
- Document ID and title
- Published/Draft status
- Last update date

### API Keys

Manage API keys for external integrations.

#### List API keys for a project
```bash
canvas keys list 1
```

Shows all API keys for project ID 1, including:
- Key name
- Partial key value (first 16 characters)
- Creation date

### Configuration

View current configuration.

```bash
canvas config
```

Shows:
- Canvas API URL
- Whether API key is set

## Examples

### Setting up for Astro blog
```bash
# Set your Canvas credentials
export CANVAS_API_URL=http://localhost:8080/api
export CANVAS_API_KEY=your_key_from_project_settings

# List your projects
canvas projects list

# List documents in project 1
canvas docs list 1

# View API keys for project 1
canvas keys list 1
```

### Creating a new project for a blog
```bash
# Create project
canvas projects create "My Blog"

# Get the project ID from the output (e.g., 2)
# Use this ID in your Astro blog .env.local:
# CANVAS_PROJECT_ID=2
```

## Help

```bash
canvas --help          # Show all commands
canvas projects --help # Show projects subcommands
canvas docs --help     # Show docs subcommands
canvas keys --help     # Show keys subcommands
```

## Authentication

The CLI uses API keys for authentication. Generate API keys in the Canvas Admin Panel:

1. Go to your Project → Settings
2. Find the "API Keys" section
3. Click "Generate New Key"
4. Copy the key and set it as `CANVAS_API_KEY` environment variable

## Version

```bash
canvas --version
```

Shows the CLI version.