Skip to content

k2on/cli

Repository files navigation

Koons CLI

Simple typesafe CLI framework.

import { run, router, command } from "@koons/cli";
import z from "zod";

const cli = router({
    add: router({
        module: command()
            .describe("Add a module")
            .input(z.object({ name: z.number() }))
            .fn(({ input }) => {
                console.log(`Adding module: "${input.name}"`);
            }),
    }),
    version: command()
        .describe("Show the CLI version")
        .fn(() => console.log("Version 1.0")),
});

run(cli);

Will allow you to run:

my-cli add module acme-core # "Adding module: "acme-core""
my-cli version # "Version 1.0"

Installation

Genesis

genesis add cli

npm

yarn add @koons/cli