NEW: Parser for import of images

This commit is contained in:
Jean-Claude 2021-06-28 22:15:38 +02:00
parent 076c8cf845
commit 6e8f63c77e
Signed by: jeanclaude
GPG Key ID: 8A300F57CBB9F63E
2 changed files with 37 additions and 13 deletions

View File

@ -12,14 +12,19 @@ data Options = Options
} deriving (Eq, Show)
data Command
= Import ImportOptions
= Import ImportOption
| Test
| NotImplemented
deriving (Eq, Show)
--- Import
data ImportOptions
= ImportNew Git.Branch
data ImportImagesOptions = ImportImagesOptions
{ importImagesIdentifer :: String
, importImagesCombine :: Bool
} deriving (Eq, Show)
data ImportOption
= ImportImages [String] ImportImagesOptions
| ImportActivate Git.Branch
| ImportDeactivate Bool
| ImportList Bool
@ -32,12 +37,24 @@ importCommand =
importParser :: Parser Command
importParser =
Import <$>
( ImportNew
<$> strOption
( long "new"
<> short 'n'
<> metavar "NAME"
<> help "Name of the new import"
( ImportImages
<$> many ( argument str
( metavar "IMAGES"
<> help "Paths to images to import"
))
<*> ( ImportImagesOptions
<$> strOption
( long "identifer"
<> short 'i'
<> metavar "IDENTIFIER"
<> help "Name to identify current import"
<> value ""
)
<*> switch
( long "combine"
<> short 'c'
<> help "combine stuff"
)
)
<|> ImportActivate
<$> strOption

View File

@ -1,13 +1,12 @@
module Command.Import where
import Command (ImportOptions(..))
import Command (ImportOption(..))
import qualified Config as Conf
import qualified Git as Git
runImport :: ImportOptions -> IO ()
runImport (ImportNew name) = do
return ()
runImport :: ImportOption -> IO ()
-- activate
runImport (ImportActivate name) = do
exists <- Git.branchExists name
case exists of
@ -17,14 +16,22 @@ runImport (ImportActivate name) = do
False -> putStrLn "Error, branch does not exists"
return ()
-- deactivate
runImport (ImportDeactivate True) = do
_ <- Git.runGit ["checkout", Conf.mainBranch]
return ()
-- list
runImport (ImportList True) = do
branches <- Git.getBranches
putStrLn $ unlines branches
return ()
-- import
runImport (ImportImages paths opts) = do
putStrLn $ show paths ++ show opts
return ()
runImport _ = do
return ()