exit with msg if no file given
This commit is contained in:
parent
5f508d7a27
commit
95bf8f3853
1 changed files with 8 additions and 0 deletions
|
@ -1,8 +1,16 @@
|
|||
module Main where
|
||||
|
||||
import Control.Monad (when)
|
||||
import Gui (runEditor)
|
||||
import System.Environment (getArgs)
|
||||
|
||||
main = do
|
||||
args <- getArgs
|
||||
when (null args) $ error (msgWithUsage "Please specify a file")
|
||||
runEditor $ head args
|
||||
|
||||
msgWithUsage :: String -> String
|
||||
msgWithUsage = \x -> x ++ "\n" ++ usage
|
||||
|
||||
usage :: String
|
||||
usage = "Usage: hedit <file>"
|
||||
|
|
Loading…
Reference in a new issue