Skip to content

Toolcraft unnamed default command crashes when root has sibling commands #402

@kamilio

Description

@kamilio

Toolcraft supports GroupConfig.default, which enables a root invocation such as wire <url>. An unnamed default command (defineCommand({ name: "", ... })) renders correctly in root help as <url>, but CLI construction crashes when the group also has sibling commands.

Minimal shape:

const ingest = defineCommand({
  name: "",
  positional: ["url"],
  params: S.Object({ url: S.String() }),
  handler: async ({ params }) => params,
})

const root = defineGroup({
  name: "",
  children: [ingest, defineCommand({ name: "init", params: S.Object({}), handler: async () => ({}) })],
  default: ingest,
})

Running any CLI command fails in Commander:

Error: Command passed to .addCommand() must have a name
- specify the name in Command constructor or using .name()

Expected: unnamed default commands should support root positional usage alongside named sibling commands, and remain represented in help as the root positional form rather than requiring an extra visible command name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions