killercup / quicli

Quickly build cool CLI apps in Rust.
https://killercup.github.io/quicli/
Apache License 2.0
540 stars 31 forks source link

Verbosity flag does not work when package name != crate name #60

Closed CAD97 closed 6 years ago

CAD97 commented 6 years ago

This was very weird to diagnose, since I couldn't figure out why it worked in playground but not in my real project (that has hyphens in its name) until I guessed that this was the problem.

When setting package.name = "crate-name", the actual crate name will be crate_name. The log filter should be registered for crate_name but is currently registered for crate-name. (It may be a failing of env_logger to not accept either, but we can do better.)

killercup commented 6 years ago

We are just using the environment variable Cargo gives us here.

Is there something we can do differently here without a build script or proc macro?

CAD97 commented 6 years ago

I'm now using env!("CARGO_PKG_NAME").replace("-","_") (mod typing that on a phone without checking syntax) which works properly for the common case of one crate in the package

No idea what to do for workspaces until cargo provides more info