January 2019
Intermediate to advanced
520 pages
14h 32m
English
We've prepared all queries, so now we can join them in a binary tool with a command-line interface. In the following code, we will parse some parameters with the clap crate, and run functions to manage users with an established Connection.
Our tool will support three commands. Declare their names as constants:
const CMD_CREATE: &str = "create";const CMD_ADD: &str = "add";const CMD_LIST: &str = "list";
Now, we can create the main function using the clap crate to parse our command-line arguments:
fn main() -> Result<(), Error> { let matches = App::new(crate_name!()) .version(crate_version!()) .author(crate_authors!()) .about(crate_description!()) .setting(AppSettings::SubcommandRequired) .arg( Arg::with_name("database") ...Read now
Unlock full access