module HMGit.Commands.Porcelain.Init.Cmd ( initCmd ) where import HMGit.Commands (Cmd (..)) import HMGit.Commands.Porcelain.Init.Core (Init, initDefault, initQuiet) import Control.Exception.Safe (MonadThrow) import Control.Monad.IO.Class (MonadIO) import Data.Foldable (asum) import qualified Options.Applicative as OA initMode :: (MonadThrow m, MonadIO m) => OA.Parser (String -> Init m) initMode :: Parser (String -> Init m) initMode = [Parser (String -> Init m)] -> Parser (String -> Init m) forall (t :: * -> *) (f :: * -> *) a. (Foldable t, Alternative f) => t (f a) -> f a asum [ (String -> Init m) -> Mod FlagFields (String -> Init m) -> Parser (String -> Init m) forall a. a -> Mod FlagFields a -> Parser a OA.flag' String -> Init m forall (m :: * -> *). MonadIO m => String -> Init m initQuiet (Mod FlagFields (String -> Init m) -> Parser (String -> Init m)) -> Mod FlagFields (String -> Init m) -> Parser (String -> Init m) forall a b. (a -> b) -> a -> b $ [Mod FlagFields (String -> Init m)] -> Mod FlagFields (String -> Init m) forall a. Monoid a => [a] -> a mconcat [ Char -> Mod FlagFields (String -> Init m) forall (f :: * -> *) a. HasName f => Char -> Mod f a OA.short Char 'q' , String -> Mod FlagFields (String -> Init m) forall (f :: * -> *) a. HasName f => String -> Mod f a OA.long String "quiet" , String -> Mod FlagFields (String -> Init m) forall (f :: * -> *) a. String -> Mod f a OA.help String "Only print error and warning messages; all other output will be suppressed." ] , (String -> Init m) -> Parser (String -> Init m) forall (f :: * -> *) a. Applicative f => a -> f a pure String -> Init m forall (m :: * -> *). (MonadThrow m, MonadIO m) => String -> Init m initDefault ] repositoryName :: OA.Parser String repositoryName :: Parser String repositoryName = Mod ArgumentFields String -> Parser String forall s. IsString s => Mod ArgumentFields s -> Parser s OA.strArgument (Mod ArgumentFields String -> Parser String) -> Mod ArgumentFields String -> Parser String forall a b. (a -> b) -> a -> b $ [Mod ArgumentFields String] -> Mod ArgumentFields String forall a. Monoid a => [a] -> a mconcat [ String -> Mod ArgumentFields String forall (f :: * -> *) a. HasMetavar f => String -> Mod f a OA.metavar String "<directory>" , String -> Mod ArgumentFields String forall (f :: * -> *) a. HasValue f => a -> Mod f a OA.value String "." , String -> Mod ArgumentFields String forall (f :: * -> *) a. String -> Mod f a OA.help String "" ] initCmd :: (MonadThrow m, MonadIO m) => OA.Mod OA.CommandFields (Cmd m) initCmd :: Mod CommandFields (Cmd m) initCmd = String -> ParserInfo (Cmd m) -> Mod CommandFields (Cmd m) forall a. String -> ParserInfo a -> Mod CommandFields a OA.command String "init" (ParserInfo (Cmd m) -> Mod CommandFields (Cmd m)) -> ParserInfo (Cmd m) -> Mod CommandFields (Cmd m) forall a b. (a -> b) -> a -> b $ Parser (Cmd m) -> InfoMod (Cmd m) -> ParserInfo (Cmd m) forall a. Parser a -> InfoMod a -> ParserInfo a OA.info ((String -> Init m) -> String -> Cmd m forall (m :: * -> *). (String -> Init m) -> String -> Cmd m CmdInit ((String -> Init m) -> String -> Cmd m) -> Parser (String -> Init m) -> Parser (String -> Cmd m) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (Parser ((String -> Init m) -> String -> Init m) forall a. Parser (a -> a) OA.helper Parser ((String -> Init m) -> String -> Init m) -> Parser (String -> Init m) -> Parser (String -> Init m) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser (String -> Init m) forall (m :: * -> *). (MonadThrow m, MonadIO m) => Parser (String -> Init m) initMode) Parser (String -> Cmd m) -> Parser String -> Parser (Cmd m) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser String repositoryName) (InfoMod (Cmd m) -> ParserInfo (Cmd m)) -> InfoMod (Cmd m) -> ParserInfo (Cmd m) forall a b. (a -> b) -> a -> b $ String -> InfoMod (Cmd m) forall a. String -> InfoMod a OA.progDesc String "Create an empty Git repository or reinitialize an existing one"