Skip to content

Commit b8ae867

Browse files
authored
Merge pull request #45 from PaulJohnson/master
Provide help message.
2 parents ec43355 + 0c336ba commit b8ae867

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

app/Main.hs

Lines changed: 14 additions & 2 deletions
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,8 +21,8 @@ main = do
1921
"cabal" -> cabalPkgs pwd
2022
_ -> stackYamlPkgs pwd
2123
when (null cfs) $
22-
error $
23-
"Used" <> name
24+
die $
25+
"Used " <> name
2426
<> "\n No .cabal files found under"
2527
<> pwd
2628
<> "\n You may need to run stack build."
@@ -31,6 +33,16 @@ 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 $
39+
"Usage: " <> progName
40+
<> " [ --cabal | --stack ]\n\n\
41+
\If neither argument is given then "
42+
<> progName
43+
<> " will infer the type by\n\
44+
\looking for dist-newstyle, .stack-work, cabal.project and stack.yaml in that order."
45+
exitSuccess
3446
let fileNames = map takeFileName files
3547
name =
3648
if

0 commit comments

Comments
 (0)