From 5ff10cac88a00d0f8b6ca48661c9ed4234b58da8 Mon Sep 17 00:00:00 2001 From: Tormod Gjeitnes Hellen <tormod.hellen@gmail.com> Date: Sun, 8 Jul 2018 22:09:15 +0000 Subject: [PATCH] =?UTF-8?q?Add=20help=20quick=20guide=20when=20test=20laun?= =?UTF-8?q?ched=20with=20no=20arguments,=20and=20document=20the=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- members/builtins/src/test.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/members/builtins/src/test.rs b/members/builtins/src/test.rs index 90dc0f5c..63c9a0d2 100644 --- a/members/builtins/src/test.rs +++ b/members/builtins/src/test.rs @@ -16,6 +16,9 @@ DESCRIPTION Tests the expressions given and returns an exit status of 0 if true, else 1. OPTIONS + --help + prints this help text + -n STRING the length of STRING is nonzero @@ -111,6 +114,10 @@ AUTHOR Written by Michael Murphy. "#; +const QUICK_GUIDE: &'static str = +r#"Usage: test [EXPRESSION] +Try 'test --help' for more information."#; + pub fn test(args: &[String]) -> Result<bool, String> { let arguments = &args[1..]; evaluate_arguments(arguments) @@ -148,7 +155,10 @@ fn evaluate_arguments(arguments: &[String]) -> Result<bool, String> { evaluate_expression(arg, operator, right_arg) }) } - None => Ok(false), + None => { + println!("{}", QUICK_GUIDE); + Ok(false) + } } } -- GitLab