Skip to content

Provide help message. #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import Hie.Locate
import Hie.Yaml
import System.Directory
import System.Environment
import System.Exit
import System.FilePath.Posix
import System.IO

main :: IO ()
main = do
Expand All @@ -19,8 +21,8 @@ main = do
"cabal" -> cabalPkgs pwd
_ -> stackYamlPkgs pwd
when (null cfs) $
error $
"Used" <> name
die $
"Used " <> name
<> "\n No .cabal files found under"
<> pwd
<> "\n You may need to run stack build."
Expand All @@ -31,6 +33,16 @@ resolveName :: FilePath -> IO String
resolveName pwd = do
args <- getArgs
files <- listDirectory pwd
when ("--help" `elem` args || "-h" `elem` args) $ do
progName <- getProgName
hPutStrLn stderr $
"Usage: " <> progName
<> " [ --cabal | --stack ]\n\n\
\If neither argument is given then "
<> progName
<> " will infer the type by\n\
\looking for dist-newstyle, .stack-work, cabal.project and stack.yaml in that order."
exitSuccess
let fileNames = map takeFileName files
name =
if
Expand Down