-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptions.hs
More file actions
44 lines (35 loc) · 1.13 KB
/
Options.hs
File metadata and controls
44 lines (35 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module Options (parseArgs, CommandType (..)) where
import Options.Applicative
import Data.Semigroup
parseArgs :: IO CommandType
parseArgs = execParser opts
data CommandType
= EncryptBMPImage { secretKey :: String, iv :: String, filename :: FilePath }
deriving (Show)
mkBMPParser :: (String -> String -> FilePath -> CommandType)
-> Parser CommandType
mkBMPParser cmdType = cmdType
<$> strOption
(long "secretKey"
<> short 'k'
<> metavar "SECRETKEY"
<> help "128-bit secret key used to generate the random numbers")
<*> strOption
(long "initialization vector"
<> short 'v'
<> metavar "IV"
<> help "128-bit initialization vector")
<*> strOption
(long "image"
<> short 'i'
<> metavar "IMAGE"
<> help "image to encrypt")
encryptBMPParser :: Parser CommandType
encryptBMPParser = mkBMPParser EncryptBMPImage
parseCommand :: Parser CommandType
parseCommand = encryptBMPParser
opts :: ParserInfo CommandType
opts = info (parseCommand <**> helper)
( fullDesc
<> progDesc "Encrypt or decrypt and image with MUGI, japanese power at your fingertips!"
<> header "MUGI - Random Number Generator")