gen-example.hs
1 {-# LANGUAGE OverloadedStrings #-} 2 3 -- | Example: Generate typed wrapper for ripgrep 4 module Main where 5 6 import Aleph.Script.Clap 7 import qualified Data.Text.IO as TIO 8 import System.IO (hPutStrLn, stderr) 9 10 main :: IO () 11 main = do 12 -- Read ripgrep short help (more manageable size) 13 help <- TIO.readFile "corpus/rg-short.txt" 14 let parsed = parseHelp help 15 16 hPutStrLn stderr $ "Parsed " ++ show (sum $ map (length . secOptions) (helpSections parsed)) ++ " options" 17 hPutStrLn stderr $ "Parsed " ++ show (length $ helpPositionals parsed) ++ " positional args" 18 19 -- Generate the module 20 TIO.putStrLn $ generateModule "Rg" "rg" parsed