pub fn parse_command_string(string: &str) -> Result<Command, CliError>
Expand description
Parses command line arguments from a string.
This function is useful for testing or when you have command line arguments stored in a string rather than from the actual command line.
§Arguments
string
- The command line string to parse
§Returns
Ok(Command)
- If parsing succeedsErr(CliError)
- If parsing fails
§Examples
use cli_command::parse_command_string;
let cmd = parse_command_string("serve --port 8080 --host localhost").unwrap();
assert_eq!(cmd.name, "serve");
assert_eq!(cmd.get_argument("port"), Some("8080"));
assert_eq!(cmd.get_argument("host"), Some("localhost"));