module Reanimate.Driver.CLI
( getDriverOptions
, Options(..)
, Command(..)
, Preset(..)
, Format(..)
, Raster(..)
, showFormat
, showRaster
) where
import Data.Char (toLower)
import Options.Applicative
import Prelude
import Reanimate.Render (FPS, Format (..), Height, Raster (..), Width)
newtype Options = Options
{ Options -> Command
optsCommand :: Command
} deriving (Int -> Options -> ShowS
[Options] -> ShowS
Options -> String
(Int -> Options -> ShowS)
-> (Options -> String) -> ([Options] -> ShowS) -> Show Options
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Options] -> ShowS
$cshowList :: [Options] -> ShowS
show :: Options -> String
$cshow :: Options -> String
showsPrec :: Int -> Options -> ShowS
$cshowsPrec :: Int -> Options -> ShowS
Show)
data Command
= Raw
{ Command -> String
rawOutputFolder :: FilePath
, Command -> Int
rawFrameOffset :: Int
, Command -> Bool
rawPrettyPrint :: Bool
}
| Test
| Check
| View
{ Command -> Bool
viewDetach :: Bool
}
| Render
{ Command -> Maybe String
renderTarget :: Maybe String
, Command -> Maybe Int
renderFPS :: Maybe FPS
, Command -> Maybe Int
renderWidth :: Maybe Width
, Command -> Maybe Int
renderHeight :: Maybe Height
, Command -> Bool
renderCompile :: Bool
, Command -> Maybe Format
renderFormat :: Maybe Format
, Command -> Maybe Preset
renderPreset :: Maybe Preset
, Command -> Raster
renderRaster :: Raster
, Command -> Bool
renderPartial :: Bool
, Command -> Bool
renderHash :: Bool
}
deriving (Int -> Command -> ShowS
[Command] -> ShowS
Command -> String
(Int -> Command -> ShowS)
-> (Command -> String) -> ([Command] -> ShowS) -> Show Command
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Command] -> ShowS
$cshowList :: [Command] -> ShowS
show :: Command -> String
$cshow :: Command -> String
showsPrec :: Int -> Command -> ShowS
$cshowsPrec :: Int -> Command -> ShowS
Show)
data Preset = Youtube | ExampleGif | Quick | MediumQ | HighQ | LowFPS
deriving (Int -> Preset -> ShowS
[Preset] -> ShowS
Preset -> String
(Int -> Preset -> ShowS)
-> (Preset -> String) -> ([Preset] -> ShowS) -> Show Preset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Preset] -> ShowS
$cshowList :: [Preset] -> ShowS
show :: Preset -> String
$cshow :: Preset -> String
showsPrec :: Int -> Preset -> ShowS
$cshowsPrec :: Int -> Preset -> ShowS
Show)
readRaster :: String -> Maybe Raster
readRaster :: String -> Maybe Raster
readRaster String
raster =
case (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower String
raster of
String
"none" -> Raster -> Maybe Raster
forall a. a -> Maybe a
Just Raster
RasterNone
String
"auto" -> Raster -> Maybe Raster
forall a. a -> Maybe a
Just Raster
RasterAuto
String
"inkscape" -> Raster -> Maybe Raster
forall a. a -> Maybe a
Just Raster
RasterInkscape
String
"rsvg" -> Raster -> Maybe Raster
forall a. a -> Maybe a
Just Raster
RasterRSvg
String
"imagemagick" -> Raster -> Maybe Raster
forall a. a -> Maybe a
Just Raster
RasterMagick
String
_ -> Maybe Raster
forall a. Maybe a
Nothing
showRaster :: Raster -> String
showRaster :: Raster -> String
showRaster Raster
RasterNone = String
"none"
showRaster Raster
RasterAuto = String
"auto"
showRaster Raster
RasterInkscape = String
"inkscape"
showRaster Raster
RasterRSvg = String
"rsvg"
showRaster Raster
RasterMagick = String
"imagemagick"
readFormat :: String -> Maybe Format
readFormat :: String -> Maybe Format
readFormat String
fmt =
case (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower String
fmt of
String
"mp4" -> Format -> Maybe Format
forall a. a -> Maybe a
Just Format
RenderMp4
String
"gif" -> Format -> Maybe Format
forall a. a -> Maybe a
Just Format
RenderGif
String
"webm" -> Format -> Maybe Format
forall a. a -> Maybe a
Just Format
RenderWebm
String
_ -> Maybe Format
forall a. Maybe a
Nothing
showFormat :: Format -> String
showFormat :: Format -> String
showFormat Format
RenderMp4 = String
"mp4"
showFormat Format
RenderGif = String
"gif"
showFormat Format
RenderWebm = String
"webm"
readPreset :: String -> Maybe Preset
readPreset :: String -> Maybe Preset
readPreset String
preset =
case (Char -> Char) -> ShowS
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower String
preset of
String
"youtube" -> Preset -> Maybe Preset
forall a. a -> Maybe a
Just Preset
Youtube
String
"gif" -> Preset -> Maybe Preset
forall a. a -> Maybe a
Just Preset
ExampleGif
String
"quick" -> Preset -> Maybe Preset
forall a. a -> Maybe a
Just Preset
Quick
String
"medium" -> Preset -> Maybe Preset
forall a. a -> Maybe a
Just Preset
MediumQ
String
"high" -> Preset -> Maybe Preset
forall a. a -> Maybe a
Just Preset
HighQ
String
"lowfps" -> Preset -> Maybe Preset
forall a. a -> Maybe a
Just Preset
LowFPS
String
_ -> Maybe Preset
forall a. Maybe a
Nothing
showPreset :: Preset -> String
showPreset :: Preset -> String
showPreset Preset
Youtube = String
"youtube"
showPreset Preset
ExampleGif = String
"gif"
showPreset Preset
Quick = String
"quick"
showPreset Preset
MediumQ = String
"medium"
showPreset Preset
HighQ = String
"high"
showPreset Preset
LowFPS = String
"lowfps"
options :: Parser Options
options :: Parser Options
options = Command -> Options
Options (Command -> Options) -> Parser Command -> Parser Options
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Command
commandP
commandP :: Parser Command
commandP :: Parser Command
commandP = Mod CommandFields Command -> Parser Command
forall a. Mod CommandFields a -> Parser a
subparser(
String -> ParserInfo Command -> Mod CommandFields Command
forall a. String -> ParserInfo a -> Mod CommandFields a
command String
"test" ParserInfo Command
testCommand
Mod CommandFields Command
-> Mod CommandFields Command -> Mod CommandFields Command
forall a. Semigroup a => a -> a -> a
<> String -> Mod CommandFields Command
forall a. String -> Mod CommandFields a
commandGroup String
"Internal commands"
Mod CommandFields Command
-> Mod CommandFields Command -> Mod CommandFields Command
forall a. Semigroup a => a -> a -> a
<> Mod CommandFields Command
forall (f :: * -> *) a. Mod f a
internal )
Parser Command -> Parser Command -> Parser Command
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Mod CommandFields Command -> Parser Command
forall a. Mod CommandFields a -> Parser a
hsubparser
( String -> ParserInfo Command -> Mod CommandFields Command
forall a. String -> ParserInfo a -> Mod CommandFields a
command String
"check" ParserInfo Command
checkCommand
Mod CommandFields Command
-> Mod CommandFields Command -> Mod CommandFields Command
forall a. Semigroup a => a -> a -> a
<> String -> ParserInfo Command -> Mod CommandFields Command
forall a. String -> ParserInfo a -> Mod CommandFields a
command String
"view" ParserInfo Command
viewCommand
Mod CommandFields Command
-> Mod CommandFields Command -> Mod CommandFields Command
forall a. Semigroup a => a -> a -> a
<> String -> ParserInfo Command -> Mod CommandFields Command
forall a. String -> ParserInfo a -> Mod CommandFields a
command String
"render" ParserInfo Command
renderCommand
Mod CommandFields Command
-> Mod CommandFields Command -> Mod CommandFields Command
forall a. Semigroup a => a -> a -> a
<> String -> ParserInfo Command -> Mod CommandFields Command
forall a. String -> ParserInfo a -> Mod CommandFields a
command String
"raw" ParserInfo Command
rawCommand
)
Parser Command -> Parser Command -> Parser Command
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParserInfo Command -> Parser Command
forall a. ParserInfo a -> Parser a
infoParser ParserInfo Command
viewCommand
rawCommand :: ParserInfo Command
rawCommand :: ParserInfo Command
rawCommand = Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info Parser Command
parse
(String -> InfoMod Command
forall a. String -> InfoMod a
progDesc String
"Output raw SVGs for animation at 60 fps. Used internally by viewer.")
where
parse :: Parser Command
parse = String -> Int -> Bool -> Command
Raw
(String -> Int -> Bool -> Command)
-> Parser String -> Parser (Int -> Bool -> Command)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption
( String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"output" Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<>
Char -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'o' Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<>
String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"PATH" Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<>
String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help String
"Output folder" Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<>
String -> Mod OptionFields String
forall (f :: * -> *) a. HasValue f => a -> Mod f a
value String
".")
Parser (Int -> Bool -> Command)
-> Parser Int -> Parser (Bool -> Command)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto
( String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"offset" Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<>
String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"NUMBER" Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<>
String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help String
"Frame offset" Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<>
Int -> Mod OptionFields Int
forall (f :: * -> *) a. HasValue f => a -> Mod f a
value Int
0)
Parser (Bool -> Command) -> Parser Bool -> Parser Command
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Mod FlagFields Bool -> Parser Bool
switch
( String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"pretty-print" Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<>
Char -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'p' Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<>
String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help String
"Pretty print svg")
testCommand :: ParserInfo Command
testCommand :: ParserInfo Command
testCommand = Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info (Parser Command
parse Parser Command -> Parser (Command -> Command) -> Parser Command
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> Parser (Command -> Command)
forall a. Parser (a -> a)
helper)
(String -> InfoMod Command
forall a. String -> InfoMod a
progDesc String
"Generate 10 frames spread out evenly across the animation. Used \
\internally by the test-suite.")
where
parse :: Parser Command
parse = Command -> Parser Command
forall (f :: * -> *) a. Applicative f => a -> f a
pure Command
Test
checkCommand :: ParserInfo Command
checkCommand :: ParserInfo Command
checkCommand = Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info Parser Command
parse
(String -> InfoMod Command
forall a. String -> InfoMod a
progDesc String
"Run a system's diagnostic and report any missing external dependencies.")
where
parse :: Parser Command
parse = Command -> Parser Command
forall (f :: * -> *) a. Applicative f => a -> f a
pure Command
Check
viewCommand :: ParserInfo Command
viewCommand :: ParserInfo Command
viewCommand = Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info Parser Command
parse
(String -> InfoMod Command
forall a. String -> InfoMod a
progDesc String
"Play animation in browser window.")
where
parse :: Parser Command
parse = Bool -> Command
View
(Bool -> Command) -> Parser Bool -> Parser Command
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Mod FlagFields Bool -> Parser Bool
switch
(String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"detach" Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> Char -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'd')
renderCommand :: ParserInfo Command
renderCommand :: ParserInfo Command
renderCommand = Parser Command -> InfoMod Command -> ParserInfo Command
forall a. Parser a -> InfoMod a -> ParserInfo a
info Parser Command
parse
(String -> InfoMod Command
forall a. String -> InfoMod a
progDesc String
"Render animation to file.")
where
parse :: Parser Command
parse = Maybe String
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Bool
-> Maybe Format
-> Maybe Preset
-> Raster
-> Bool
-> Bool
-> Command
Render
(Maybe String
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Bool
-> Maybe Format
-> Maybe Preset
-> Raster
-> Bool
-> Bool
-> Command)
-> Parser (Maybe String)
-> Parser
(Maybe Int
-> Maybe Int
-> Maybe Int
-> Bool
-> Maybe Format
-> Maybe Preset
-> Raster
-> Bool
-> Bool
-> Command)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser String -> Parser (Maybe String)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Mod OptionFields String -> Parser String
forall s. IsString s => Mod OptionFields s -> Parser s
strOption (String -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"target"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> Char -> Mod OptionFields String
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'o'
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"FILE"
Mod OptionFields String
-> Mod OptionFields String -> Mod OptionFields String
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields String
forall (f :: * -> *) a. String -> Mod f a
help String
"Write output to FILE"))
Parser
(Maybe Int
-> Maybe Int
-> Maybe Int
-> Bool
-> Maybe Format
-> Maybe Preset
-> Raster
-> Bool
-> Bool
-> Command)
-> Parser (Maybe Int)
-> Parser
(Maybe Int
-> Maybe Int
-> Bool
-> Maybe Format
-> Maybe Preset
-> Raster
-> Bool
-> Bool
-> Command)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto
(String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"fps" Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"FPS"
Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help String
"Set frames per second."))
Parser
(Maybe Int
-> Maybe Int
-> Bool
-> Maybe Format
-> Maybe Preset
-> Raster
-> Bool
-> Bool
-> Command)
-> Parser (Maybe Int)
-> Parser
(Maybe Int
-> Bool
-> Maybe Format
-> Maybe Preset
-> Raster
-> Bool
-> Bool
-> Command)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto
(String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"width" Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> Char -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'w' Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"PIXELS"
Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help String
"Set video width."))
Parser
(Maybe Int
-> Bool
-> Maybe Format
-> Maybe Preset
-> Raster
-> Bool
-> Bool
-> Command)
-> Parser (Maybe Int)
-> Parser
(Bool
-> Maybe Format
-> Maybe Preset
-> Raster
-> Bool
-> Bool
-> Command)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Int -> Parser (Maybe Int)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ReadM Int -> Mod OptionFields Int -> Parser Int
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ReadM Int
forall a. Read a => ReadM a
auto
(String -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"height" Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> Char -> Mod OptionFields Int
forall (f :: * -> *) a. HasName f => Char -> Mod f a
short Char
'h'
Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"PIXELS" Mod OptionFields Int
-> Mod OptionFields Int -> Mod OptionFields Int
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Int
forall (f :: * -> *) a. String -> Mod f a
help String
"Set video height."))
Parser
(Bool
-> Maybe Format
-> Maybe Preset
-> Raster
-> Bool
-> Bool
-> Command)
-> Parser Bool
-> Parser
(Maybe Format -> Maybe Preset -> Raster -> Bool -> Bool -> Command)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Mod FlagFields Bool -> Parser Bool
switch (String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"compile"
Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help String
"Compile source code before rendering.")
Parser
(Maybe Format -> Maybe Preset -> Raster -> Bool -> Bool -> Command)
-> Parser (Maybe Format)
-> Parser (Maybe Preset -> Raster -> Bool -> Bool -> Command)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Format -> Parser (Maybe Format)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ReadM Format -> Mod OptionFields Format -> Parser Format
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ((String -> Maybe Format) -> ReadM Format
forall a. (String -> Maybe a) -> ReadM a
maybeReader String -> Maybe Format
readFormat)
(String -> Mod OptionFields Format
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"format" Mod OptionFields Format
-> Mod OptionFields Format -> Mod OptionFields Format
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Format
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"FMT"
Mod OptionFields Format
-> Mod OptionFields Format -> Mod OptionFields Format
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Format
forall (f :: * -> *) a. String -> Mod f a
help String
"Video format: mp4, gif, webm"))
Parser (Maybe Preset -> Raster -> Bool -> Bool -> Command)
-> Parser (Maybe Preset)
-> Parser (Raster -> Bool -> Bool -> Command)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser Preset -> Parser (Maybe Preset)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ReadM Preset -> Mod OptionFields Preset -> Parser Preset
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ((String -> Maybe Preset) -> ReadM Preset
forall a. (String -> Maybe a) -> ReadM a
maybeReader String -> Maybe Preset
readPreset)
(String -> Mod OptionFields Preset
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"preset" Mod OptionFields Preset
-> Mod OptionFields Preset -> Mod OptionFields Preset
forall a. Semigroup a => a -> a -> a
<> (Preset -> String) -> Mod OptionFields Preset
forall a (f :: * -> *). (a -> String) -> Mod f a
showDefaultWith Preset -> String
showPreset
Mod OptionFields Preset
-> Mod OptionFields Preset -> Mod OptionFields Preset
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Preset
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"TYPE"
Mod OptionFields Preset
-> Mod OptionFields Preset -> Mod OptionFields Preset
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Preset
forall (f :: * -> *) a. String -> Mod f a
help String
"Parameter presets: youtube, gif, quick, medium, high"))
Parser (Raster -> Bool -> Bool -> Command)
-> Parser Raster -> Parser (Bool -> Bool -> Command)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReadM Raster -> Mod OptionFields Raster -> Parser Raster
forall a. ReadM a -> Mod OptionFields a -> Parser a
option ((String -> Maybe Raster) -> ReadM Raster
forall a. (String -> Maybe a) -> ReadM a
maybeReader String -> Maybe Raster
readRaster)
(String -> Mod OptionFields Raster
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"raster" Mod OptionFields Raster
-> Mod OptionFields Raster -> Mod OptionFields Raster
forall a. Semigroup a => a -> a -> a
<> (Raster -> String) -> Mod OptionFields Raster
forall a (f :: * -> *). (a -> String) -> Mod f a
showDefaultWith Raster -> String
showRaster
Mod OptionFields Raster
-> Mod OptionFields Raster -> Mod OptionFields Raster
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Raster
forall (f :: * -> *) a. HasMetavar f => String -> Mod f a
metavar String
"RASTER"
Mod OptionFields Raster
-> Mod OptionFields Raster -> Mod OptionFields Raster
forall a. Semigroup a => a -> a -> a
<> Raster -> Mod OptionFields Raster
forall (f :: * -> *) a. HasValue f => a -> Mod f a
value Raster
RasterNone
Mod OptionFields Raster
-> Mod OptionFields Raster -> Mod OptionFields Raster
forall a. Semigroup a => a -> a -> a
<> String -> Mod OptionFields Raster
forall (f :: * -> *) a. String -> Mod f a
help String
"Raster engine: none, auto, inkscape, rsvg, imagemagick")
Parser (Bool -> Bool -> Command)
-> Parser Bool -> Parser (Bool -> Command)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Mod FlagFields Bool -> Parser Bool
switch
(String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"partial"
Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help String
"Produce partial animation even if frame generation was \
\interrupted by ctrl-c")
Parser (Bool -> Command) -> Parser Bool -> Parser Command
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Bool -> Bool -> Mod FlagFields Bool -> Parser Bool
forall a. a -> a -> Mod FlagFields a -> Parser a
flag Bool
True Bool
False
(String -> Mod FlagFields Bool
forall (f :: * -> *) a. HasName f => String -> Mod f a
long String
"disable-hashing"
Mod FlagFields Bool -> Mod FlagFields Bool -> Mod FlagFields Bool
forall a. Semigroup a => a -> a -> a
<> String -> Mod FlagFields Bool
forall (f :: * -> *) a. String -> Mod f a
help String
"Disable SVG dedup via hashing. This might improve performance \
\if all your frames are unique.")
opts :: ParserInfo Options
opts :: ParserInfo Options
opts = Parser Options -> InfoMod Options -> ParserInfo Options
forall a. Parser a -> InfoMod a -> ParserInfo a
info (Parser Options
options Parser Options -> Parser (Options -> Options) -> Parser Options
forall (f :: * -> *) a b. Applicative f => f a -> f (a -> b) -> f b
<**> Parser (Options -> Options)
forall a. Parser (a -> a)
helper )
( InfoMod Options
forall a. InfoMod a
fullDesc
InfoMod Options -> InfoMod Options -> InfoMod Options
forall a. Semigroup a => a -> a -> a
<> String -> InfoMod Options
forall a. String -> InfoMod a
progDesc String
"This program contains an animation which can either be viewed \
\in a web-browser or rendered to disk."
)
getDriverOptions :: IO Options
getDriverOptions :: IO Options
getDriverOptions = ParserPrefs -> ParserInfo Options -> IO Options
forall a. ParserPrefs -> ParserInfo a -> IO a
customExecParser (PrefsMod -> ParserPrefs
prefs PrefsMod
showHelpOnError) ParserInfo Options
opts