mirror of
https://github.com/tealdeer-rs/tealdeer.git
synced 2026-08-09 09:49:10 +02:00
Add support for spaces in commands (#75)
For example "git commit". Fixes #74.
This commit is contained in:
parent
89a2595495
commit
91c7a412f0
2 changed files with 21 additions and 2 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
18
tests/lib.rs
18
tests/lib.rs
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue