Attribute Macro auto_version::auto_version[][src]

#[auto_version]
Expand description

This attribute macro which prints the value of CARGO_PKG_VERSION and exits with status code 0 if the command line arguments include either -v or --version

In the case where the code is not compiled with cargo, the version will be replaced with the message “auto_version macro only works for projects compiled with cargo”.

Example:

use auto_version::auto_version;

#[auto_version]
fn main() {
    // executed code
}

Then, when this binary is called with binary -v or binary --version, it will output the Cargo.toml version without any specific formatting:

$ ./binary -v
$ 0.1.0