Installation
This guide will help you set up the CLI Template for your project.
Prerequisites
Before you begin, make sure you have:
- Node.js (version 20 or higher)
- pnpm (version 9.12.3 or higher)
- Git
Getting Started
Clone the repository:
bashgit clone https://github.com/Shironex/cli-template.git my-cli cd my-cli
Install dependencies:
bashpnpm install
Update package.json:
- Change the
name
field to your CLI name - Update the
description
field - Update the
author
field - Update the
bin
field if you want to change the command name
- Change the
Link the CLI globally (optional but recommended for development):
bashpnpm link --global
This will allow you to use your CLI directly from the command line:
bashcli-template interactive
Instead of:
bashpnpm dev
Start development:
bash# If linked globally: cli-template interactive # If not linked: pnpm dev
Development Commands
The template includes several useful development commands:
pnpm dev
- Start development mode with interactive commandpnpm build
- Build the CLI for productionpnpm test
- Run testspnpm test:watch
- Run tests in watch modepnpm test:coverage
- Generate test coverage reportpnpm lint
- Run ESLintpnpm format
- Format code with Prettierpnpm docs:dev
- Start documentation development serverpnpm link --global
- Link the CLI globally for developmentpnpm unlink --global
- Unlink the CLI from global installation
Project Structure
my-cli/
├── src/
│ ├── commands/ # CLI commands
│ ├── utils/ # Utility functions
│ │── lib/ # Main logic folder
│ └── index.ts # Main entry point
├── tests/ # Test files
├── docs/ # Documentation
├── package.json # Project configuration
├── tsconfig.json # TypeScript configuration
├── vitest.config.ts # Vitest configuration
└── tsup.config.ts # Build configuration
Next Steps
- Basic Commands - Learn how to create and use commands
- Interactive Mode - Add interactive prompts to your CLI
- Testing - Write and run tests for your commands
- Best Practices - Tips for CLI development