Add support for spaces in commands (#75)

For example "git commit".

Fixes #74.
This commit is contained in:
Jonathan Dahan 2019-01-14 03:28:48 -05:00 committed by Danilo Bargen
commit 91c7a412f0
2 changed files with 21 additions and 2 deletions

View file

@ -44,7 +44,7 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
const USAGE: &str = "
Usage:
tldr [options] <command>
tldr [options] <command>...
tldr [options]
Options:
@ -79,7 +79,7 @@ const MAX_CACHE_AGE: i64 = 2_592_000; // 30 days
#[derive(Debug, Deserialize)]
struct Args {
arg_command: Option<String>,
arg_command: Option<Vec<String>>,
flag_help: bool,
flag_version: bool,
flag_list: bool,
@ -303,6 +303,7 @@ fn main() {
// Show command from cache
if let Some(ref command) = args.arg_command {
let command = command.join("-");
// Check cache for freshness
check_cache(&args, &cache);

View file

@ -257,3 +257,21 @@ fn test_correct_rendering_with_config() {
.success()
.stdout(similar(expected));
}
#[test]
fn test_spaces_find_command() {
let testenv = TestEnv::new();
testenv
.command()
.args(&["--update"])
.assert()
.success()
.stdout(contains("Successfully updated cache."));
testenv
.command()
.args(&["git", "checkout"])
.assert()
.success();
}