1 {-# LANGUAGE AllowAmbiguousTypes #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 {-# LANGUAGE NoMonomorphismRestriction #-}
4 {-# LANGUAGE TypeApplications #-}
5 {-# LANGUAGE UndecidableInstances #-}
6 module Symantic.CLI.Test where
8 -- import Data.Monoid (Monoid(..))
9 -- import Data.Ord (Ord(..))
10 -- import Text.Show (Show(..))
11 import Control.Applicative (Applicative(..), Alternative(..))
12 import Control.Monad (Monad(..))
14 import Data.Ord (Ord(..))
15 import Data.Either (Either(..))
16 import Data.Function (($), (.))
17 import Data.Functor ((<$>))
18 import Data.List.NonEmpty (NonEmpty(..))
19 import Data.Maybe (Maybe(..))
20 import Data.Semigroup (Semigroup(..))
21 import Data.String (String)
22 import Data.Void (Void)
23 import Text.Show (Show(..))
24 import Type.Reflection (Typeable)
25 import System.IO (IO, print, stderr, putStrLn)
26 import System.Environment (getArgs)
28 import qualified Data.Set as Set
29 import qualified Data.Text.Lazy.IO as TL
30 import qualified Symantic.Document.Term as Doc
31 import qualified Symantic.Document.Term.IO as DocIO
32 import qualified System.IO as IO
37 { opts_git_dir :: String
38 , opts_work_tree :: String
45 Opts <$> longOpt "git-dir" "GIT_DIR" (var "path")
46 <*> longOpt "work-tree" "X" (var "path")
47 <*> longOpt "int" 0 (var "name"))
57 help_ d = help (d::DocIO.TermIO)
60 help_ "print some help" $
61 tagged (Tag 'h' "help") nothing
62 <.> response @DocIO.TermIO
65 help_ "print the version" $
66 tagged (TagLong "version") nothing
72 (Clone <$> longOpt "branch" "master" (var "name"))
73 <?> response @(Opts,Clone)
77 (Push <$> longOpt "set-upstream" False (just True)
78 <*> longOpt "all" False (just True))
80 <.> many1 (var @String "refspec")
81 <.> response @(Opts,Push,[String])
87 data Clone = Clone String
89 data Push = Push Bool Bool
92 doc0 = DocIO.runTermIO IO.stderr $ plainDoc api
93 help0 = DocIO.runTermIO IO.stderr $ helpDoc api
101 route_help = return $ helpDoc api
102 route_version = return "1.0"
103 route_clone (cloneOpts::Clone) =
104 return (gitOpts,cloneOpts)
105 route_push pushOpts refs =
106 return (gitOpts,pushOpts,refs)
110 instance Typeable (a,b) => IOType (a,b)
111 instance Typeable (a,b,c) => IOType (a,b,c)
113 instance (Show (a,b), Typeable (a,b)) => Outputable (a,b)
114 instance (Show (a,b,c), Typeable (a,b,c)) => Outputable (a,b,c)
115 instance Outputable Opts
117 parser0 = parser api route_git
121 putStrLn $ "args: " <> show args
122 parser0 $ parseArgs args