OpenCyphal / yakut

Simple CLI tool for diagnostics and debugging of Cyphal networks
https://opencyphal.org
MIT License
47 stars 10 forks source link

CLI is dumb #103

Open thirtytwobits opened 5 months ago

thirtytwobits commented 5 months ago

The Yakut CLI is overly rigid and unintelligent. Example:

> yakut mon -h
Usage: yakut monitor [OPTIONS]
Try 'yakut monitor --help' for help.

Error: No such option: -h

> yakut mon --path ~/.dsdl/types

Usage: yakut monitor [OPTIONS]
Try 'yakut monitor --help' for help.

Error: No such option: --path

> yakut mon --help --path ~/.dsdl/types

Usage: yakut monitor [OPTIONS]
Try 'yakut monitor --help' for help.

Error: No such option: --path

> yakut mon --help

(no --path option shown)

> yakut mon

Error: Run `yakut compile <path>/uavcan` to compile DSDL namespace 'uavcan'

Modern CLIs are flexible and smart. click is obviously retrograde and should be disused.

pavel-kirienko commented 5 months ago

Can you recommend alternatives to Click? If not, we could perhaps extract main command options (such as --verbose, --json, etc) into a shared decorator and use it with subcommands as well. Or maybe it would be easier to extend Click to make subcommands inherit options from its parent command.

Related: https://github.com/pallets/click/discussions/2189

thirtytwobits commented 5 months ago

Use argparse and argcomplete. You should separate the concerns of the CLI from the library in a similar way one separates view from view-model in a GUI application.