Commit 45f01962 authored by Iustin Pop's avatar Iustin Pop
Browse files

Implement error checks for extra arguments

Neither hbal nor hn1 take any arguments beside the options, so if any
are passed is most likely an unintended error. This patch aborts in such
cases.
parent 050b0c38
......@@ -141,7 +141,12 @@ iterateDepth ini_tbl max_rounds ktn kti nmlen imlen cmd_strs oneline =
main :: IO ()
main = do
cmd_args <- System.getArgs
(opts, _) <- CLI.parseOpts cmd_args "hbal" options defaultOptions optShowHelp
(opts, args) <- CLI.parseOpts cmd_args "hbal" options
defaultOptions optShowHelp
unless (null args) $ do
hPutStrLn stderr "Error: this program doesn't take any arguments."
exitWith $ ExitFailure 1
when (optShowVer opts) $ do
putStr $ CLI.showVersion "hbal"
......
......@@ -123,7 +123,12 @@ options =
main :: IO ()
main = do
cmd_args <- System.getArgs
(opts, _) <- CLI.parseOpts cmd_args "hn1" options defaultOptions optShowHelp
(opts, args) <- CLI.parseOpts cmd_args "hn1" options
defaultOptions optShowHelp
unless (null args) $ do
hPutStrLn stderr "Error: this program doesn't take any arguments."
exitWith $ ExitFailure 1
when (optShowVer opts) $ do
printf $ CLI.showVersion "hn1"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment