Skip to content

Chaining commands when using Guides #537

@mrleblanc101

Description

@mrleblanc101

I'm creating a CLI using city and clack/prompts like so:

#!/usr/bin/env node
import { defineCommand, runMain } from "citty";
import { createCommand } from "./commands/create.js";
import { initCommand } from "./commands/init.js";
import { startCommand } from "./commands/start.js";
import { stopCommand } from "./commands/stop.js";
import { statusCommand } from "./commands/status.js";
import { syncCommand } from "./commands/sync.js";

const main = defineCommand({
  meta: {
    name: "kubeo-cli",
    version: "0.1.0",
    description: "Kubeo CLI",
  },
  subCommands: {
    create: createCommand,
    init: initCommand,
    start: startCommand,
    stop: stopCommand,
    status: statusCommand,
    sync: syncCommand,
  },
});

runMain(main);

I have individual command, but also a master create which prompt to run the init and sync command.
How would I handle intro/outro and guides ?
Currently, the guide are broken, and I'm wondering if i'm doing something wrong or if I need to manage this manually.

Image

The sub-commands are called like so:

const runInit = await p.confirm({
  message: "Run init now?",
  initialValue: true,
});

if (p.isCancel(runInit) || !runInit) {
  p.outro(`Run \`cd ${name} && kubeo-cli init\` when you're ready.`);
  return;
}

spawnSync("kubeo-cli", ["init"], { stdio: "inherit" });
p.outro("Done.");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Needs triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions