@@ -9,7 +9,7 @@ import Control.Arrow (first)
99import Control.Monad (forM_)
1010import Data.Char (isAlphaNum, isNumber)
1111import Data.List (foldl')
12−import Data.List (intercalate)
12+import Data.List (intercalate, isPrefixOf)
1313import Data.Version (Version (..))
1414import System.Directory (canonicalizePath, copyFile)
1515import System.Environment (getArgs, getProgName)
@@ -31,7 +31,13 @@ main = do
3131 files <- getRecursiveContents (const $ return False) srcDir
3232
3333 case args of
34− [dstDir] -> do
34+ -- When the argument begins with hyphens, it's more likely that the user
35+ -- intends to attempt some arguments like ("--help", "-h", "--version", etc.)
36+ -- rather than create directory with that name.
37+ -- If dstDir begins with hyphens, the guard will prevent it from creating
38+ -- directory with that name so we can fall to the second alternative
39+ -- which prints a usage info for user.
40+ [dstDir] | not ("-" `isPrefixOf` dstDir) -> do
3541 forM_ files $ \file -> do
3642 let dst = dstDir </> file
3743 src = srcDir </> file