Skip to main content

crate_cli/
const.rs

1/// Manifest file name every Cargo package root is looked up under.
2pub const CARGO_TOML: &str = "Cargo.toml";
3
4/// `[workspace]` table key in a Cargo manifest.
5pub(crate) const TOML_WORKSPACE: &str = "workspace";
6
7/// `[package]` table key in a Cargo manifest.
8pub(crate) const TOML_PACKAGE: &str = "package";
9
10/// `[package].version` key in a Cargo manifest.
11pub(crate) const TOML_VERSION: &str = "version";
12
13/// `[package].name` key in a Cargo manifest.
14pub(crate) const TOML_NAME: &str = "name";
15
16/// `[workspace.members]` array key in a Cargo manifest.
17pub(crate) const TOML_MEMBERS: &str = "members";
18
19/// `[package].publish` key in a Cargo manifest.
20pub(crate) const TOML_PUBLISH_KEY: &str = "publish";
21
22/// `[dependencies]` table key in a Cargo manifest.
23pub(crate) const TOML_DEPENDENCIES: &str = "dependencies";
24
25/// `[dev-dependencies]` table key in a Cargo manifest.
26pub(crate) const TOML_DEV_DEPENDENCIES: &str = "dev-dependencies";
27
28/// `[build-dependencies]` table key in a Cargo manifest.
29pub(crate) const TOML_BUILD_DEPENDENCIES: &str = "build-dependencies";
30
31/// `[target]` table key in a Cargo manifest.
32pub(crate) const TOML_TARGET: &str = "target";
33
34/// `path` key of a local dependency entry in a Cargo manifest.
35pub(crate) const TOML_PATH: &str = "path";
36
37/// `bump` subcommand name accepted by the command-line interface.
38pub(crate) const CLI_BUMP: &str = "bump";
39
40/// `publish` subcommand name accepted by the command-line interface.
41pub(crate) const CLI_PUBLISH: &str = "publish";
42
43/// `sync` subcommand name accepted by the command-line interface.
44pub(crate) const CLI_SYNC: &str = "sync";
45
46/// `-h` / `--help` flag of the command-line interface.
47pub(crate) const CLI_FLAG_HELP: &str = "--help";
48
49/// `-v` / `--version` flag of the command-line interface.
50pub(crate) const CLI_FLAG_VERSION: &str = "--version";
51
52/// `--patch` flag selecting a patch version bump.
53pub(crate) const CLI_FLAG_PATCH: &str = "--patch";
54
55/// `--minor` flag selecting a minor version bump.
56pub(crate) const CLI_FLAG_MINOR: &str = "--minor";
57
58/// `--major` flag selecting a major version bump.
59pub(crate) const CLI_FLAG_MAJOR: &str = "--major";
60
61/// `--release` flag dropping any pre-release identifier.
62pub(crate) const CLI_FLAG_RELEASE: &str = "--release";
63
64/// `--alpha` flag selecting an `alpha` pre-release bump.
65pub(crate) const CLI_FLAG_ALPHA: &str = "--alpha";
66
67/// `--beta` flag selecting a `beta` pre-release bump.
68pub(crate) const CLI_FLAG_BETA: &str = "--beta";
69
70/// `--rc` flag selecting an `rc` pre-release bump.
71pub(crate) const CLI_FLAG_RC: &str = "--rc";
72
73/// `--check` flag switching a subcommand into check-only mode.
74pub(crate) const CLI_FLAG_CHECK: &str = "--check";
75
76/// `--manifest-path` flag naming the manifest to operate on.
77pub(crate) const CLI_FLAG_MANIFEST_PATH: &str = "--manifest-path";
78
79/// `--max-retries` flag bounding publish retry attempts.
80pub(crate) const CLI_FLAG_MAX_RETRIES: &str = "--max-retries";
81
82/// `--fix` flag passed to `cargo clippy`.
83pub(crate) const CLI_FLAG_FIX: &str = "--fix";
84
85/// `--workspace` flag passed to `cargo clippy`.
86pub(crate) const CLI_FLAG_WORKSPACE: &str = "--workspace";
87
88/// `--all-targets` flag passed to `cargo clippy`.
89pub(crate) const CLI_FLAG_ALL_TARGETS: &str = "--all-targets";
90
91/// `--allow-dirty` flag passed to `cargo clippy` and `cargo publish`.
92pub(crate) const CLI_FLAG_ALLOW_DIRTY: &str = "--allow-dirty";
93
94/// `--no-verify` flag passed to `cargo publish`.
95pub(crate) const CLI_FLAG_NO_VERIFY: &str = "--no-verify";
96
97/// Cargo executable spawned as a child process.
98pub(crate) const CARGO: &str = "cargo";
99
100/// Cargo subcommand that reformats the workspace.
101pub(crate) const CARGO_FMT: &str = "fmt";
102
103/// Cargo subcommand that uploads a package to the registry.
104pub(crate) const CARGO_PUBLISH: &str = "publish";
105
106/// `clippy` subcommand / component name.
107pub(crate) const CLIPPY: &str = "clippy";
108
109/// Standalone `cargo-clippy` executable probed on `PATH`.
110pub(crate) const CARGO_CLIPPY: &str = "cargo-clippy";
111
112/// Rust toolchain manager executable spawned as a child process.
113pub(crate) const RUSTUP: &str = "rustup";
114
115/// `component` subcommand of the Rust toolchain manager.
116pub(crate) const RUSTUP_COMPONENT: &str = "component";
117
118/// `alpha` pre-release identifier applied by a version bump.
119pub(crate) const PRERELEASE_ALPHA: &str = "alpha";
120
121/// `beta` pre-release identifier applied by a version bump.
122pub(crate) const PRERELEASE_BETA: &str = "beta";
123
124/// Literal prefix of a Rust `#[derive(...)]` attribute.
125pub(crate) const DERIVE_PREFIX: &str = "#[derive(";
126
127/// Regular expression capturing the trait list of a `#[derive(...)]` attribute.
128pub(crate) const DERIVE_PATTERN: &str = r"#\[derive\s*\(([^)]+)\)\]";
129
130/// Panic message when the derive-pattern regular expression fails to compile.
131pub(crate) const ERROR_DERIVE_PATTERN_INVALID: &str = "Invalid regex pattern";
132
133/// Error message when installing the clippy component fails.
134pub(crate) const ERROR_CLIPPY_INSTALL_FAILED: &str = "failed to install cargo-clippy";
135
136/// Error message when `cargo clippy --fix` exits non-zero.
137pub(crate) const ERROR_CLIPPY_FIX_FAILED: &str = "cargo clippy --fix failed";
138
139/// Error message when `cargo fmt` exits non-zero.
140pub(crate) const ERROR_FMT_FAILED: &str = "cargo fmt failed";
141
142/// Error message when `[workspace.package].version` is absent from a manifest.
143pub(crate) const ERROR_WORKSPACE_PACKAGE_VERSION_MISSING: &str =
144    "workspace.package.version not found";
145
146/// Error message when `[package].version` is absent from a manifest.
147pub(crate) const ERROR_PACKAGE_VERSION_MISSING: &str = "package.version not found";
148
149/// Error message when a manifest declares neither version location.
150pub(crate) const ERROR_NO_VERSION_SLOT: &str =
151    "neither [package] nor [workspace.package] found in Cargo.toml";
152
153/// Error message when a manifest version slot is not a string.
154pub(crate) const ERROR_VERSION_NOT_STRING: &str = "version field is not a string";
155
156/// Report text emitted when a workspace declares no members.
157pub(crate) const REPORT_ZERO_WORKSPACE_MEMBERS: &str = "0 workspace members";
158
159/// Report placeholder used when no shared workspace version exists.
160pub(crate) const REPORT_PER_MEMBER_VERSION: &str = "per-member";
161
162/// `cargo publish` stderr fragment for an already uploaded package.
163pub(crate) const STDERR_ALREADY_BEEN_UPLOADED: &str = "already been uploaded";
164
165/// `cargo publish` stderr fragment for an already published package.
166pub(crate) const STDERR_IS_ALREADY_PUBLISHED: &str = "is already published";
167
168/// `cargo publish` stderr fragment for a version already on the registry index.
169pub(crate) const STDERR_ALREADY_ON_INDEX: &str = "already exists on crates.io index";