summaryrefslogtreecommitdiff
path: root/fig-cli/src/Fig/CLI.hs
blob: 36df60d512f580f98bde1df753527c1b4e90ae1b (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
{-# Language ApplicativeDo #-}

module Fig.CLI where

import Fig.Prelude

import Options.Applicative

import Fig.Utils.SExpr

newtype Opts = Opts
  { sexpr :: Text
  }

parseOpts :: Parser Opts
parseOpts = do
  sexpr <- strArgument (metavar "SEXPR" <> help "S-expression to parse")
  pure Opts{..}

main :: IO ()
main = do
  opts <- execParser $ info (parseOpts <**> helper)
    ( fullDesc
    <> Options.Applicative.header "fig-cli - assorted tools"
    )
  let sexp = parseSExpr opts.sexpr
  log $ tshow (sexp, pretty <$> sexp)