New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

kuri-cli

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kuri-cli

A modern TypeScript CLI framework with dependency injection and decorator-based command definition. Combines Inversify (IoC) and Commander.js for building modular, type-safe CLI applications.

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
0
Created
Source

Kuri

npm version License: MIT

Kuri is a modern, IoC-style CLI framework written in TypeScript that empowers developers to build elegant, scalable, and maintainable command-line applications.

Features

  • Decorator-based API - Define commands, options, and arguments using TypeScript decorators
  • Dependency Injection - Built-in IoC container with constructor and property injection
  • Type Safety - Leverage TypeScript's type system for better development experience
  • Modular Architecture - Split CLI applications into multiple commands and modules
  • Extensible Design - Easily extensible for adding custom functionality
  • Zero Configuration - Works out of the box with sensible defaults

Installation

# Using npm
npm install kuri-cli

# Using yarn
yarn add kuri-cli

# Using pnpm
pnpm add kuri-cli

Quick Start

import 'reflect-metadata';
import { Kuri, Command, Option, Action } from 'kuri-cli';

@Command({
  name: 'greet',
  description: 'Greet a person'
})
class GreetCommand {
  @Option('-n, --name <name>', 'Name to greet', 'World')
  private name: string;

  @Action()
  public execute(): void {
    console.log(`Hello, ${this.name}!`);
  }
}

async function main() {
  const kuri = new Kuri({
    name: 'my-cli',
    version: '1.0.0',
    commands: [GreetCommand]
  });

  await kuri.parseAsync(process.argv);
}

main().catch(console.error);

Run your CLI:

$ ts-node index.ts greet --name Developer
Hello, Developer!

Core Concepts

Command

Use the @Command decorator to define CLI commands:

@Command({
  name: 'serve',
  description: 'Start the server',
  aliases: ['start', 's']
})
class ServeCommand {
  // ...
}

Options

Use @Option and @RequiredOption decorators for command options:

@Option('-p, --port <port>', 'Port number', '3000')
private port: string;

@RequiredOption('-c, --config <path>', 'Config file path')
private configPath: string;

Arguments

Use the @Argument decorator for positional arguments:

@Argument('file', 'File to process', 'default.txt')
private file: string;

Action

Mark the method to execute when the command runs using @Action:

@Action()
public execute(): void {
  // Command implementation
}

Dependency Injection

Kuri provides built-in dependency injection through Inversify:

@Injectable()
class ConfigService {
  public getConfig(): object {
    return { /* config */ };
  }
}

@Command({ name: 'start' })
class StartCommand {
  constructor(@Inject(ConfigService) private config: ConfigService) {}
  
  @Action()
  execute() {
    const config = this.config.getConfig();
    // Use config...
  }
}

// Register service in container
const kuri = new Kuri({
  name: 'my-cli',
  version: '1.0.0',
  commands: [StartCommand],
});

Examples

Check the examples directory for more examples

Keywords

kuri

FAQs

Package last updated on 09 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts