Bat: BUG subcommand wasn't recognized

Created on 17 Sep 2019  路  4Comments  路  Source: sharkdp/bat

Reasonable samples:

touch cache.c
bat cache.c
bat -- cache.c

touch scratch.text
bat scratch.text
bat -- scratch.text

Unexpected output for all four examples:

error: The subcommand 'scratch.text' wasn't recognized
        Did you mean 'cache'?

If you believe you received this message in error, try re-running with 'bat -- scratch.text'

USAGE:
    bat [OPTIONS] [FILE]...
    bat <SUBCOMMAND>

For more information try --help

Behavior I expect as a user:

  1. Running the suggestion bat -- scratch.text should work
  2. bat shouldn't suggest a sub-command when a file exists
Two more I want as a user:

  1. Sub-commands should be implemented as flags to keep the CLI interface clean. I want to easily autocomplete commands and options separate from files. bat <tab> vs bat --<tab>
  2. No "Did you mean..." messages. I like the feature in a compiler, not so much on the command line. Why? 1) These are power tools--I can diagnose an clear error myself. 2) Overly verbose messages eat up terminal space.

What do you think? I'd be happy to open a couple PRs this weekend on whatever is decided.

question

Most helpful comment

I'm on macOS v0.12.1 now and cannot reproduce either. I'll check the version of my home Linux install tonight.

All 4 comments

I can't confirm this bug on my computer setup (macOS, bat v0.12.1).

What platform are you using?
What's the output when you run bat --version?


Running the suggestion bat -- scratch.text should work

We've had issues with mixing positional arguments (files) with subcommands in the past (#245 #557 #584). It should have been fixed with the latest release, though.

Sub-commands should be implemented as flags to keep the CLI interface clean. I want to easily autocomplete commands and options separate from files. bat vs bat --

There have been a few discussions in #557 about renaming bat --cache to a flag or separate binary, but I believe they've been put on pause since subcommands were fixed in v0.12.1.

No "Did you mean..." messages. I like the feature in a compiler, not so much on the command line. Why? 1) These are power tools--I can diagnose an clear error myself. 2) Overly verbose messages eat up terminal space.

I believe that's a feature of clap, the crate that bat uses for command line argument parsing. I think it's possible to disable it. That would need to be up for discussion, though.

I'm on macOS v0.12.1 now and cannot reproduce either. I'll check the version of my home Linux install tonight.

I'm going to close this for now. Let us know if you can reproduce the bug on v0.12.1.

Tested 0.12.1 on Linux, bug fixed. Sorry for the delay. Love the program :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sharkdp picture sharkdp  路  3Comments

niedzielski picture niedzielski  路  3Comments

gAmUssA picture gAmUssA  路  3Comments

yannallain picture yannallain  路  3Comments

lilyball picture lilyball  路  3Comments