File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 20
20
21
21
module Main ( main ) where
22
22
23
+ import Data.Char ( intToDigit )
23
24
import Diffr.Util.ArgumentsProcessor ( containsHelpArgument , extractOutputFile )
24
25
import System.Environment ( getArgs )
25
26
import System.Exit ( exitFailure , exitSuccess )
@@ -33,7 +34,7 @@ main = do
33
34
printUsage
34
35
exitFailure
35
36
else do
36
- print ( length args )
37
+ print ( [intToDigit ( length args )] ++ " arguments " )
37
38
print ( extractOutputFile args )
38
39
exitSuccess
39
40
Original file line number Diff line number Diff line change @@ -24,16 +24,21 @@ import Data.Char ( toLower )
24
24
25
25
-- | 'containsHelpArgument' checks if the given list of strings contains the help argument.
26
26
containsHelpArgument :: [[Char ]] -> Bool
27
- containsHelpArgument args = any isHelpArgument args
27
+ containsHelpArgument args = any isHelpArgument ( map ( map toLower ) args )
28
28
29
29
-- | 'extractOutputFile' extracts the output file argument from a list of strings.
30
30
extractOutputFile :: [[Char ]] -> [Char ]
31
- extractOutputFile args
32
- | " -o" == head args = head ( tail args )
33
- | otherwise = extractOutputFile ( tail args )
31
+ extractOutputFile args = case args of
32
+ [] -> " "
33
+ (" -o" : [] ) -> " "
34
+ (" -o" : xs) -> head ( xs )
35
+ _ -> extractOutputFile ( tail args )
34
36
35
37
-- | 'isHelpArgument' checks if a string is a help argument.
36
38
isHelpArgument :: [Char ] -> Bool
37
- isHelpArgument arg
38
- | ' -' == ( head arg ) = isHelpArgument( tail arg )
39
- | otherwise = " help" == ( map toLower arg )
39
+ isHelpArgument arg = case arg of
40
+ [] -> False
41
+ (' -' : [] ) -> False
42
+ (' -' : xs) -> isHelpArgument( xs )
43
+ " help" -> True
44
+ _ -> False
You can’t perform that action at this time.
0 commit comments