Skip to content

Commit 8adfffb

Browse files
committed
If -h or --help is given then print helpful message and exit.
1 parent ec43355 commit 8adfffb

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/Main.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import Hie.Locate
99
import Hie.Yaml
1010
import System.Directory
1111
import System.Environment
12+
import System.Exit
1213
import System.FilePath.Posix
14+
import System.IO
1315

1416
main :: IO ()
1517
main = do
@@ -19,7 +21,7 @@ main = do
1921
"cabal" -> cabalPkgs pwd
2022
_ -> stackYamlPkgs pwd
2123
when (null cfs) $
22-
error $
24+
die $
2325
"Used" <> name
2426
<> "\n No .cabal files found under"
2527
<> pwd
@@ -31,6 +33,12 @@ resolveName :: FilePath -> IO String
3133
resolveName pwd = do
3234
args <- getArgs
3335
files <- listDirectory pwd
36+
when ("--help" `elem` args || "-h" `elem` args) $ do
37+
progName <- getProgName
38+
hPutStrLn stderr $ "Usage: " <> progName <> " [ --cabal | --stack ]\n\n\
39+
\If neither argument is given then " <> progName <> " will infer the type by\n\
40+
\looking for dist-newstyle, .stack-work, cabal.project and stack.yaml in that order."
41+
exitSuccess
3442
let fileNames = map takeFileName files
3543
name =
3644
if

0 commit comments

Comments
 (0)