c4spar / deno-cliffy

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...

Home Page:https://cliffy.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug: version number is not printed using `-v`

KnorpelSenf opened this issue · comments

When I run the CLI using -v, I expect it to behave the same way as when I pass --version. This is not the case.

// cli.ts
import { Command } from "https://deno.land/x/cliffy@v0.25.7/command/mod.ts";

await new Command()
  .name("sitemap")
  .version("0.1.0")
  .description("demo")
  .parse(Deno.args);

This works:

$ deno run cli.ts --version
sitemap 0.1.0

However, the option -v is not recognised:

$ deno run cli.ts -v

  Usage:   sitemap
  Version: 0.1.0  

  Description:

    demo

  Options:

    -h, --help     - Show this help.                            
    -V, --version  - Show the version number for this program.  

  error: Unknown option "-v". Did you mean option "-h"?

It doesn't work with a capital V. Try a small one and it will work

Exactly, cliffy uses capilatized V for the version option. Try deno run cli.ts -V.
It's also possible to change it to lowercase with the .versionOption() method, see https://cliffy.io/docs@v0.25.7/command/help#customize-version-option.

Oh, I did not even notice that, sorry. What's the rationale behind this? :)

Np 🙂 I prefer to use -v for verbose and -V for version option and I think many other cli's do the same, including the deno cli which is built with clap a rust framework which also uses -V by default.

I see, that makes sense. Gonna get used to that now, thanks for elaborating