# @moostjs/event-cli

<p align="center">
<img src="../../moost-logo.png" width="450px"><br>
<a  href="https://github.com/moostjs/moostjs/blob/main/LICENSE">
    <img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" />
</a>
</p>

Welcome to `@moostjs/event-cli`, a Moostjs library designed to handle CLI events within your Moost application. This package provides decorators that simplify the creation of command line interface handlers in a structured and declarative manner.

**Note:** As `@moostjs/event-cli` is under active development, breaking changes can be expected.

## Overview

The `@moostjs/event-cli` module is crucial for making Moost applications responsive to CLI events. By leveraging this module, you can create handlers for these events in a structured, and clear manner.

## Installation

```bash
npm install @moostjs/event-cli
```

## Quick Start

```ts
import { CliApp, Cli, CliOption, Controller, Param } from '@moostjs/event-cli'

@Controller()
class Commands {
  @Cli('hello/:name')
  greet(
    @Param('name') name: string,
    @CliOption('uppercase', 'u') uppercase: boolean,
  ) {
    const output = `Hello, ${name}!`
    return uppercase ? output.toUpperCase() : output
  }
}

new CliApp()
  .controllers(Commands)
  .useHelp({ name: 'my-cli' })
  .useOptions([{ keys: ['help'], description: 'Display instructions for the command.' }])
  .start()
```

```bash
my-cli hello World        # → Hello, World!
my-cli hello World -u     # → HELLO, WORLD!
my-cli hello --help       # → generated help output
```

See the [official documentation](https://moost.org/cliapp/) for commands, options, controllers, the help system, and interceptors.

## Getting Started

To start a new Moost CLI project, you can run the following command:

```bash
npm create moost -- --cli
```

You can also provide a name for your project:

```bash
npm create moost my-cli-app -- --cli
```

This command will initiate a setup tool that will guide you through the project initialization process. It will prompt you to configure:

- Project and package name.
- Whether to add OXC lint and formatter (oxlint + oxfmt).

## [Official Documentation](https://moost.org/cliapp/)

## AI Agent Skills

A unified Moost skill for AI coding agents (Claude Code, Cursor, Windsurf, Codex, etc.) is available:

```bash
npx skills add moostjs/moostjs
```

## Contributing

We are excited to welcome contributors who are passionate about improving Moostjs. No matter your level of experience, your unique perspective and skills can make valuable contributions to our growing community.

Here are some basic steps to get you started:

1. **Fork the Repo:** Navigate to [moostjs](https://github.com/moostjs/moostjs) and fork the repository to your own GitHub account.

2. **Clone the Repo:** Clone the forked repository to your local machine.

3. **Create a Branch:** Make a new branch for your feature or bug fix.

4. **Make your Changes:** Implement your feature or fix the bug and commit the changes to your branch.

5. **Make a Pull Request:** Navigate back to your forked repo and press the "New pull request" button.

Don't hesitate to ask for help if you need it. We believe in fostering a friendly and respectful environment for all contributors.

Thank you for your interest in Moostjs. We look forward to building something amazing together!
