| Crates.io | shift |
| lib.rs | shift |
| version | 0.2.0 |
| created_at | 2025-07-08 01:42:18.000994+00 |
| updated_at | 2025-07-08 03:39:18.847046+00 |
| description | A command-line argument parser |
| homepage | |
| repository | https://codeberg.org/eze-works/argsplz |
| max_upload_size | |
| id | 1741954 |
| size | 16,371 |
Unobtrusive library for processing command line arguments.
pub fn main() {
// Assume this is the result of std::env::args()
let cmdline = ["git", "--help", "commit", "--message", "hello"];
let mut args = shift::parse(
cmdline.into_iter().map(|s| s.to_string()).collect()
).unwrap();
// Detect help flags
if args.shift_flag("help") || args.shift_flag("h") {
// Show help
}
// Detect positional arguments with known values (aka "commands")
if args.shift_operand_with_value("commit") {
// Do the commit
}
// Get the value of an option
let Some(value) = args.shift_option("m").or_else(|| args.shift_option("message")) else {
panic!();
};
assert_eq!(value, "hello");
}