Skip to content

enhancement: Bare subcommand-parent commands (docker, kubectl) allowed with no args #72

@jonchun

Description

@jonchun

Summary

When a subcommand-parent command like docker or kubectl is invoked with zero arguments, the len(args) > 0 check fails and validation falls through to the generic manifest lookup. If a base manifest exists for the parent (e.g., docker), the bare command passes validation.

Location

validator/validator.go:48-50

if manifest.SubcommandCommands[command] && len(args) > 0 {
    return validateSubcommand(command, args, registry)
}

Impact

Low — bare docker, kubectl, etc. just show help text, which is harmless. But it creates an inconsistency: docker images is rejected (no manifest) while bare docker is allowed.

Suggested Fix

Either require a subcommand for commands in SubcommandCommands, or document this as intentional:

if manifest.SubcommandCommands[command] {
    if len(args) == 0 {
        return &ValidationError{Message: fmt.Sprintf("'%s' requires a subcommand.", command)}
    }
    return validateSubcommand(command, args, registry)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: lowNice to fix - minor improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions