arcanis / clipanion

Type-safe CLI library / framework with no runtime dependencies
https://mael.dev/clipanion/
1.12k stars 66 forks source link

feat: print used flag instead of property name in validation error #69

Closed bgotink closed 3 years ago

bgotink commented 3 years ago

As I may have mentioned before, I've got a CLI with options generated based on a JSON Schema. To ensure the names don't clash (e.g. if there's an option called execute) all option properties are prefixed with option_. Validation errors contain this option name, which is confusing.

Even without my weird naming, I would argue that showing the actually used option rather than the property name is more user friendly.

Before:

ai build all --unknown-target foo
Usage Error: Invalid option validation for option_unknownTarget: expected a valid enumeration value (got "foo")

After:

ai build all --unknown-target foo
Usage Error: Invalid option validation for --unknown-target: expected a valid enumeration value (got "foo")
arcanis commented 3 years ago

Makes sense 👍