Skip to content

Argument parsing error: directory positional argument is swallowed by -d flag when using all #121

@SnazzyNivesh522

Description

@SnazzyNivesh522

When using the -d (or --debris) flag with the all keyword, the subsequent positional argument (the directory path) is incorrectly parsed as a choice for the -d flag. This results in an invalid choice error.

However, using the assignment syntax (e.g., -d=all) works as expected.

Reproduction Steps

  1. Install pyclean (v3.6.0).
  2. Run the command:
    pyclean -d all ./
  3. Observe the error:
    pyclean: error: argument -d/--debris: invalid choice: './' (choose from all, cache, coverage, ...)
    

Expected Behavior

The CLI should recognize all as the argument for -d and ./ as the positional directory argument.

Actual Behavior

The parser attempts to include ./ as a choice for the -d flag's list of topics.

Environment

  • pyclean version: 3.6.0
  • Python version: 3.12.12
  • OS: AlmaLinux 9.7 (Moss Jungle Cat)
  • Installation Method: Poetry

Additional Context

The issue seems to be that -d accepts multiple values (nargs='*'). When all is provided without an equals sign, the parser continues to consume following strings.

  • Fails: pyclean -d all ./
  • Works: pyclean -d=all ./
  • Works: pyclean ./ -d all

Metadata

Metadata

Assignees

No one assigned

    Labels

    usabilityAffects user experience

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions