Skip to content

feat(cli): add --version / -V flag to root command #313

@margaretjgu

Description

@margaretjgu

Summary

elastic --version currently fails with an unknown option error. The version is only accessible via elastic version (a subcommand). Nearly all CLIs expose -V / --version as a root flag, and many users will try this by instinct.

Expected behaviour

$ elastic --version
0.1.1
$ elastic -V
0.1.1

Implementation

Commander supports this natively:

program.version(VERSION, '-V, --version', 'Print the elastic CLI version')

Add this call in src/cli.ts alongside the existing program.name(...) setup. The elastic version subcommand can remain for JSON output (elastic version --json).

Metadata

Metadata

Assignees

No one assigned

    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