From efe3e74be3205aa767f9bf3adef73ed60319865d Mon Sep 17 00:00:00 2001 From: Nicolas Pouillard Date: Fri, 16 Jan 2015 22:52:35 +0100 Subject: [PATCH] Treat command names as case-insensitive --- hx.hs | 6 +++++- tests/SHA256.t/TESTRECIPE | 42 +++++++++++++++++++++++++++++++++++++++ tests/SHA256.t/stdin | 1 + tests/SHA256.t/stdout | 1 + 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 tests/SHA256.t/TESTRECIPE create mode 100644 tests/SHA256.t/stdin create mode 100644 tests/SHA256.t/stdout diff --git a/hx.hs b/hx.hs index 1bcc64b..fbfff9d 100644 --- a/hx.hs +++ b/hx.hs @@ -606,6 +606,8 @@ mainArgs _ = error $ unlines ["Unexpected arguments." ,"" ,"List of supported commands:" ,"" + ,"Command names are case-insensitive: SHA256 is equivalent to sha256." + ,"" ,"# ADDRESSES" ,"hx addr" ,"hx validaddr [
]" @@ -751,4 +753,6 @@ mainArgs _ = error $ unlines ["Unexpected arguments." ] main :: IO () -main = mainArgs . map B8.pack =<< getArgs +main = mainArgs . toLowerFirst . map B8.pack =<< getArgs + where toLowerFirst [] = [] + toLowerFirst (x:xs) = B8.map toLower x : xs diff --git a/tests/SHA256.t/TESTRECIPE b/tests/SHA256.t/TESTRECIPE new file mode 100644 index 0000000..ff1ebaa --- /dev/null +++ b/tests/SHA256.t/TESTRECIPE @@ -0,0 +1,42 @@ +#!/bin/bash + +testname=SHA256.t +command=hx +args=( SHA256 ) +exit_code=0 +stdin_file=stdin +stdout_file=stdout +stderr_file=/dev/null +sources=( ) +products=( ) + +# Environment variables: +env_vars=( ) + +setup(){ + : Perform here actions to be run before the tested program +} + +munge(){ + : Munge here the results of the tested program to ease the check +} + +check(){ + check_exit_code && + check_stderr && + check_stdout && + check_products && + : Perform here extra checks on the tested program +} + +explain(){ + explain_exit_code + explain_stdout + explain_stderr + explain_products + : Explain here more potential differences +} + +teardown(){ + : Undo here the actions of setup +} diff --git a/tests/SHA256.t/stdin b/tests/SHA256.t/stdin new file mode 100644 index 0000000..79638b2 --- /dev/null +++ b/tests/SHA256.t/stdin @@ -0,0 +1 @@ +c4bbcb1fbec99d65bf59d85c8cb62ee2db963f0fe106f483d9afa73bd4e39a8a diff --git a/tests/SHA256.t/stdout b/tests/SHA256.t/stdout new file mode 100644 index 0000000..99703db --- /dev/null +++ b/tests/SHA256.t/stdout @@ -0,0 +1 @@ +b867db875479bcc0287352cdaa4a1755689b8338777d0915e9acd9f6edbc96cb