]> Git — Sourcephile - doclang.git/blob - cli/Textphile/CLI.hs
Fix megaparsec-8 update
[doclang.git] / cli / Textphile / CLI.hs
1 {-# LANGUAGE AllowAmbiguousTypes #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 {-# LANGUAGE NoMonomorphismRestriction #-}
4 {-# LANGUAGE TypeApplications #-}
5 {-# OPTIONS_GHC -Wno-missing-signatures #-}
6 module Textphile.CLI where
7
8 import Control.Monad (Monad(..))
9 import Data.Bool
10 import Data.Function (($))
11 import Data.Semigroup (Semigroup(..))
12 import Data.Text (Text)
13 import Data.Void (Void)
14 import Symantic.CLI as CLI
15 import qualified Data.Text.Lazy.IO as TL
16 import qualified Symantic.Document as Doc
17 import qualified Symantic.RNC.Write as RNC
18 import qualified System.IO as IO
19 import qualified Textphile.DTC.Sym as DTC
20
21 import Textphile.CLI.Lang
22 import Textphile.CLI.Utils
23 import Textphile.CLI.Compile
24 import Textphile.CLI.Source
25
26 parseAPI = parser @Void @Doc api run
27
28 api =
29 program "textphile" $
30 api_commands <!>
31 api_help True <!>
32 api_version
33 run =
34 run_commands :!:
35 run_help api :!:
36 run_version
37
38 api_commands =
39 (api_options <?>) $
40 api_command_compile <!>
41 api_command_source <!>
42 api_command_schema
43 run_commands opts =
44 run_command_compile opts :!:
45 run_command_source opts :!:
46 run_command_schema
47
48 api_version =
49 helps l10n_help_version $
50 tag (TagLong "version") nothing
51 <.> response @Text
52 run_version =
53 return (Doc.from version <> Doc.newline)
54
55 api_command_schema =
56 helps l10n_help_command_schema $
57 command "schema" $
58 response @()
59 run_command_schema =
60 TL.hPutStrLn IO.stdout $
61 RNC.writeRNC DTC.schema DTC.schema