Skip to content

Commit

Permalink
Implement basic CLI
Browse files Browse the repository at this point in the history
This completes the basic API for the command line interface. I went with
getArgs over any of the other third-party libraries due to the simple
nature of the API. No need to complicate and add another dependency.
  • Loading branch information
mmwtsn committed Mar 13, 2016
1 parent db1fe00 commit 83902ab
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
module Main where

import System.Environment
import System.Exit
import Lib

-- Apply user-supplied arguments from ARGV over parser
main :: IO ()
main = getArgs >>= parse

-- Parse input for known commands, flags, or fall through to help
parse :: [String] -> IO ()
parse ["add-done"] = addDone >> exit
parse ["add-todo"] = addTodo >> exit
parse ["standup"] = standup >> exit
parse ["-v"] = version >> exit
parse ["--version"] = version >> exit
parse ["-h"] = help >> exit
parse ["--help"] = help >> exit
parse _ = help >> exit

-- Helper functions for CLI version, usage information, and exit codes
version, help, exit :: IO ()
version = putStrLn "v0.0.0"
help = putStrLn $
unlines [ "standups [COMMAND] [-v | --version] [-h | --help]"
, ""
, "Where COMMAND is one of:"
, ""
, " new Reset the in-progress standup"
, " add-done Add a task to the in-progress done"
, " add-todo Add a task to the in-progress todo"
, " standups Run `add-todo` then archive the standup"
]
exit = exitWith ExitSuccess

0 comments on commit 83902ab

Please sign in to comment.