module HMGit.Commands.Porcelain.Add.Cmd ( addCmd ) where import HMGit.Commands (Cmd (..)) import HMGit.Commands.Porcelain.Add.Core (Add (..), AddCfg (..), addDefault, addDryRun) import Control.Exception.Safe (MonadCatch) import Control.Monad.IO.Class (MonadIO) import Data.Foldable (asum) import qualified Options.Applicative as OA addMode :: (MonadCatch m, MonadIO m) => OA.Parser (Add m) addMode :: Parser (Add m) addMode = [Parser (Add m)] -> Parser (Add m) forall (t :: * -> *) (f :: * -> *) a. (Foldable t, Alternative f) => t (f a) -> f a asum [ Add m -> Mod FlagFields (Add m) -> Parser (Add m) forall a. a -> Mod FlagFields a -> Parser a OA.flag' Add m forall (m :: * -> *). (MonadCatch m, MonadIO m) => Add m addDryRun (Mod FlagFields (Add m) -> Parser (Add m)) -> Mod FlagFields (Add m) -> Parser (Add m) forall a b. (a -> b) -> a -> b $ [Mod FlagFields (Add m)] -> Mod FlagFields (Add m) forall a. Monoid a => [a] -> a mconcat [ String -> Mod FlagFields (Add m) forall (f :: * -> *) a. HasName f => String -> Mod f a OA.long String "dry-run" , Char -> Mod FlagFields (Add m) forall (f :: * -> *) a. HasName f => Char -> Mod f a OA.short Char 'n' , String -> Mod FlagFields (Add m) forall (f :: * -> *) a. String -> Mod f a OA.help String "Don’t actually add the file(s), just show if they exist and/or will be ignored." ] , Add m -> Parser (Add m) forall (f :: * -> *) a. Applicative f => a -> f a pure Add m forall (m :: * -> *). (MonadIO m, MonadCatch m) => Add m addDefault ] optAddPathspecs :: OA.Parser [String] optAddPathspecs :: Parser [String] optAddPathspecs = Parser String -> Parser [String] forall (f :: * -> *) a. Alternative f => f a -> f [a] OA.many (Parser String -> Parser [String]) -> Parser String -> Parser [String] forall a b. (a -> b) -> a -> b $ ReadM String -> Mod ArgumentFields String -> Parser String forall a. ReadM a -> Mod ArgumentFields a -> Parser a OA.argument ReadM String forall s. IsString s => ReadM s OA.str (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 "<pathspec>..." , String -> Mod ArgumentFields String forall (f :: * -> *) a. String -> Mod f a OA.help (String -> Mod ArgumentFields String) -> String -> Mod ArgumentFields String forall a b. (a -> b) -> a -> b $ [String] -> String unwords [ String "Files to add content from." , String "see the pathspec entry in gitglossary(7)." ] ] addCmd :: (MonadCatch m, MonadIO m) => OA.Mod OA.CommandFields (Cmd m) addCmd :: Mod CommandFields (Cmd m) addCmd = String -> ParserInfo (Cmd m) -> Mod CommandFields (Cmd m) forall a. String -> ParserInfo a -> Mod CommandFields a OA.command String "add" (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 (Add m -> AddCfg -> Cmd m forall (m :: * -> *). Add m -> AddCfg -> Cmd m CmdAdd (Add m -> AddCfg -> Cmd m) -> Parser (Add m) -> Parser (AddCfg -> Cmd m) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> (Parser (Add m -> Add m) forall a. Parser (a -> a) OA.helper Parser (Add m -> Add m) -> Parser (Add m) -> Parser (Add m) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> Parser (Add m) forall (m :: * -> *). (MonadCatch m, MonadIO m) => Parser (Add m) addMode) Parser (AddCfg -> Cmd m) -> Parser AddCfg -> Parser (Cmd m) forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b <*> ([String] -> AddCfg AddCfg ([String] -> AddCfg) -> Parser [String] -> Parser AddCfg forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Parser [String] optAddPathspecs)) (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 "Add file contents to the index"