Skip to content

Commit

Permalink
Add support for spaces in commands (#75)
Browse files Browse the repository at this point in the history
For example "git commit".

Fixes #74.
  • Loading branch information
Jonathan Dahan authored and dbrgn committed Jan 14, 2019
1 parent 89a2595 commit 91c7a41
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const VERSION: &str = env!("CARGO_PKG_VERSION");
const USAGE: &str = "
Usage:
tldr [options] <command>
tldr [options] <command>...
tldr [options]
Options:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);

Expand Down
18 changes: 18 additions & 0 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

0 comments on commit 91c7a41

Please sign in to comment.