{-# LANGUAGE OverloadedStrings #-} module Main where import Data.ByteString.Lazy (ByteString) import Data.ByteString.Lazy qualified as LB import Options.Applicative ((<**>)) import Options.Applicative qualified as O import System.Process.Typed qualified as P data Options = Options { optCommand :: Command } deriving (Show) data Command = List | Show deriving (Show) optionsParser :: O.Parser Options optionsParser = Options <$> commandParser commandParser :: O.Parser Command commandParser = O.subparser ( O.command "list" (O.info listCommandParser (O.progDesc "List all issues")) <> O.command "show" (O.info showCommandParser (O.progDesc "Show details of all issues")) ) listCommandParser :: O.Parser Command listCommandParser = pure List showCommandParser :: O.Parser Command showCommandParser = pure Show main :: IO () main = do options <- O.execParser (O.info (commandParser <**> O.helper) O.idm) files <- getFiles print files getFiles :: IO [ByteString] getFiles = fmap (LB.split 10 . snd) $ P.readProcessStdout "git ls-files --cached --exclude-standard --other"