summaryrefslogtreecommitdiff
path: root/Omni/Jr.hs
blob: 651aed6e4ca9d7dae0384f836e0b1a32d9c9a172 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE QuasiQuotes #-}
{-# LANGUAGE NoImplicitPrelude #-}

-- : out jr
module Omni.Jr where

import Alpha
import qualified Omni.Cli as Cli
import qualified Omni.Task as Task
import qualified Omni.Test as Test
import qualified System.Console.Docopt as Docopt
import System.Environment (withArgs)

main :: IO ()
main = Cli.main plan

plan :: Cli.Plan ()
plan =
  Cli.Plan
    { Cli.help = help,
      Cli.move = move,
      Cli.test = test,
      Cli.tidy = \_ -> pure ()
    }

help :: Cli.Docopt
help =
  [Cli.docopt|
jr

Usage:
  jr task [<args>...]
  jr work [<args>...]
  jr harvest [<args>...]
  jr test
  jr (-h | --help)

Commands:
  task     Manage tasks
  work     Track work
  harvest  Harvest wealth

Options:
  -h --help  Show this help
|]

move :: Cli.Arguments -> IO ()
move args
  | args `Cli.has` Cli.command "task" = do
      let extraArgs = Cli.getAllArgs args (Cli.argument "args")
      withArgs extraArgs Task.main
  | args `Cli.has` Cli.command "work" = do
      putText "Work command not implemented yet"
  | args `Cli.has` Cli.command "harvest" = do
      putText "Harvest command not implemented yet"
  | otherwise = putText (str <| Docopt.usage help)

test :: Test.Tree
test =
  Test.group
    "Omni.Jr"
    [ Test.unit "can run tests" <| True Test.@?= True
    ]