Skip to content

[Design] Kebab case vs. Snake case #1722

Description

@neoniobium

Case Convention for Options, Parsers, and Arguments

Details

Currently, cmd2 uses kebab case (hyphen-separated words, e.g. --kebab-case) for parameter arguments (for example --separated-words) and snake case (underscore-separated words, e.g. snake_case) for options such as the built-in settables, the built-in parsers run_script and run_pyscript, and for the (sub)parser names generated by with_annotated. There might be a few other cases as well.

While I can’t point to any general standard for CLI apps, this choice seems quite unconventional to me. I’m not aware of any widely used applications—such as git, docker, or GNU utilities—that use underscores for word separation. For example, Typer appears to automatically convert underscores to hyphens in at least some cases.

For parameter names (see #1666), such auto conversion is already happening.

In particular, the snake-case parser naming convention feels odd to me. Moreover, I find kebab case more ergonomic since it doesn’t require the user to press Shift while typing commands.

Possible solution (if any)

I’m not insisting on any changes. However, I wanted to flag this in case it isn’t a deliberate design decision, but instead a downstream result of Python’s function and variable naming conventions.

Reference

This issue #907 discusses something quite similar.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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