Skip to content

Commit

Permalink
Print usage when called with --help
Browse files Browse the repository at this point in the history
  • Loading branch information
Wilfred committed Feb 9, 2017
1 parent 61919fc commit fa30f28
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions FuzzyBranch.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import System.Directory(getCurrentDirectory, doesDirectoryExist) -- from directory
import System.Environment(getArgs)
import System.Environment(getArgs, getProgName)
import System.Exit(exitFailure)
import System.FilePath(takeDirectory)
import System.Process(readProcess)
Expand All @@ -18,6 +18,7 @@ main :: IO ()
main = do
args <- getArgs
case args of
["--help"] -> printUsage
[searchString] -> do
repoPath <- getCurrentDirectory >>= gitDirectory
case repoPath of
Expand All @@ -42,9 +43,14 @@ main = do
putStr $ unlines $ map formatBranch branches
exitFailure

_ -> do
putStrLn "Usage: git-fuzzy <substring of branch name>"
exitFailure
_ -> printUsage >> exitFailure

printUsage :: IO ()
printUsage = do
progName <- getProgName
putStrLn $ "Usage: "
putStrLn $ progName ++ " <substring of branch name>"
putStrLn $ progName ++ " <commit hash>"

formatBranch :: Branch -> String
formatBranch (LocalBranch name) = "* " ++ name
Expand Down

0 comments on commit fa30f28

Please sign in to comment.