Skip to content

mdfried **/*.md fails with cryptic 'unexpected argument' instead of a friendly hint #178

Description

@airvzxf

Summary

Running mdfried with a shell glob that expands to more than one path
fails with clap's generic error: unexpected argument ... found, which
does not explain that mdfried accepts only a single source at a time.

Reproduction

touch a.md b.md
mdfried *.md

or, in a directory tree where multiple files match:

mdfried **/PRO*.md

Actual

error: unexpected argument 'firefox-extension-efficient-tab-manager/PROPOSAL.md' found

Usage: mdfried [OPTIONS] [SOURCE]

For more information, try '--help'.

The user is left guessing that the issue is too many positional arguments
or that they need to quote the glob.

Expected

A message that points at the most common cause — a shell glob expanding
to multiple paths — and suggests either quoting the glob or running
mdfried once per file. Something like:

error: mdfried accepts a single source. If you used a shell glob, quote it
(e.g. mdfried '**/*.md') or run mdfried once per file.

Exit code should stay 2 (matches clap's default for argument errors).

Environment

  • mdfried 0.22.4
  • Linux (any shell that performs glob expansion — bash, zsh, fish, etc.)

Notes

  • The [SOURCE] positional is correctly defined as taking exactly one
    value. The problem is purely the error message — the second and later
    paths surface as 'unexpected argument' with no hint about the real
    cause.
  • Unknown flags (--foo) should keep clap's normal error, since the
    hint about a single source would be misleading there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions