-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |