exit with msg if no file given

This commit is contained in:
Armin Friedl 2016-08-07 16:26:54 +02:00
parent 5f508d7a27
commit 95bf8f3853

View file

@ -1,8 +1,16 @@
module Main where module Main where
import Control.Monad (when)
import Gui (runEditor) import Gui (runEditor)
import System.Environment (getArgs) import System.Environment (getArgs)
main = do main = do
args <- getArgs args <- getArgs
when (null args) $ error (msgWithUsage "Please specify a file")
runEditor $ head args runEditor $ head args
msgWithUsage :: String -> String
msgWithUsage = \x -> x ++ "\n" ++ usage
usage :: String
usage = "Usage: hedit <file>"