33module Main (main ) where
44
55import Codec.CBOR.Cuddle.CBOR.Gen (generateCBORTerm )
6- import Codec.CBOR.Cuddle.CDDL (Name (.. ))
7- import Codec.CBOR.Cuddle.CDDL.Resolve
8- ( fullResolveCDDL ,
9- )
6+ import Codec.CBOR.Cuddle.CDDL (Name (.. ), sortCDDL )
7+ import Codec.CBOR.Cuddle.CDDL.Resolve (
8+ fullResolveCDDL ,
9+ )
1010import Codec.CBOR.Cuddle.Parser (pCDDL )
1111import Codec.CBOR.Cuddle.Pretty ()
1212import Codec.CBOR.FlatTerm (toFlatTerm )
@@ -22,7 +22,6 @@ import System.Exit (exitFailure, exitSuccess)
2222import System.IO (hPutStrLn , stderr )
2323import System.Random (getStdGen )
2424import Text.Megaparsec (ParseErrorBundle , Parsec , errorBundlePretty , runParser )
25- import Codec.CBOR.Cuddle.CDDL (sortCDDL )
2625
2726data Opts = Opts Command String
2827
@@ -47,8 +46,8 @@ pCBOROutputFormat = eitherReader $ \case
4746 s -> Left s
4847
4948data GenOpts = GenOpts
50- { itemName :: T. Text,
51- outputFormat :: CBOROutputFormat
49+ { itemName :: T. Text
50+ , outputFormat :: CBOROutputFormat
5251 }
5352
5453pGenOpts :: Parser GenOpts
@@ -86,23 +85,20 @@ opts =
8685 ( command
8786 " format"
8887 ( info
89- ( Format <$> pFormatOpts)
90- ( progDesc " Format the provided CDDL file"
91- )
88+ (Format <$> pFormatOpts)
89+ (progDesc " Format the provided CDDL file" )
9290 )
9391 <> command
9492 " validate"
9593 ( info
9694 (pure Validate )
97- ( progDesc " Validate the provided CDDL file"
98- )
95+ (progDesc " Validate the provided CDDL file" )
9996 )
10097 <> command
10198 " gen"
10299 ( info
103100 (GenerateCBOR <$> pGenOpts)
104- ( progDesc " Generate a CBOR term matching the schema"
105- )
101+ (progDesc " Generate a CBOR term matching the schema" )
106102 )
107103 )
108104 <*> argument str (metavar " CDDL_FILE" )
@@ -126,8 +122,9 @@ run (Opts cmd cddlFile) = do
126122 putStrLnErr $ errorBundlePretty err
127123 exitFailure
128124 Right res -> case cmd of
129- Format fOpts -> let defs = if sort fOpts then sortCDDL res else res in
130- putDocW 80 $ pretty defs
125+ Format fOpts ->
126+ let defs = if sort fOpts then sortCDDL res else res
127+ in putDocW 80 $ pretty defs
131128 Validate -> case fullResolveCDDL res of
132129 Left err -> putStrLnErr (show err) >> exitFailure
133130 Right _ -> exitSuccess
0 commit comments