-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
05e2f07
commit c691dd8
Showing
5 changed files
with
46 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,44 @@ | ||
module Main (main) where | ||
|
||
import Graphics.Seangine (SeangineCli (..)) | ||
import Data.Version | ||
import Graphics.Seangine (SeangineOptions (..), runSeangine) | ||
import Options.Applicative | ||
import Paths_seangine | ||
|
||
data SeangineCli = OptVersion | OptRun SeangineOptions | ||
deriving (Eq) | ||
|
||
main :: IO () | ||
main = run =<< execParser opts' | ||
where | ||
opts' = info (parser <**> helper) infoMods | ||
infoMods = | ||
fullDesc | ||
<> header "Seangine - A Vulkan GlTF viewer" | ||
opts' = info (cliParser <**> helper) infoMods | ||
infoMods = fullDesc <> header "Seangine - A Vulkan GlTF viewer" | ||
|
||
run :: SeangineCli -> IO () | ||
run _ = pass | ||
run (OptRun opts) = runSeangine opts | ||
run OptVersion = printVersion | ||
|
||
cliParser :: Parser SeangineCli | ||
cliParser = versionParser <|> (OptRun <$> regularParser) | ||
|
||
regularParser :: Parser SeangineOptions | ||
regularParser = SeangineOptions <$> fileParser <*> deviceParser <*> debugParser | ||
|
||
parser :: Parser SeangineCli | ||
parser = SeangineCli <$> file <*> device <*> debug <*> version | ||
versionParser :: Parser SeangineCli | ||
versionParser = flag' OptVersion $ long "version" <> short 'V' <> help "Print version" | ||
|
||
debug :: Parser Bool | ||
debug = | ||
debugParser :: Parser Bool | ||
debugParser = | ||
switch $ | ||
long "verbose" | ||
<> short 'v' | ||
<> help "Debug logging (requires vulkan-validation-layers)" | ||
|
||
version :: Parser Bool | ||
version = switch $ long "version" <> short 'V' <> help "Print version" | ||
fileParser :: Parser FilePath | ||
fileParser = strArgument $ metavar "FILE" | ||
|
||
file :: Parser FilePath | ||
file = strArgument $ metavar "FILE" | ||
deviceParser :: Parser (Maybe String) | ||
deviceParser = optional $ strOption $ long "device" <> short 'd' <> help "Vulkan device" | ||
|
||
device :: Parser (Maybe String) | ||
device = optional $ strOption $ long "device" <> short 'd' <> help "Vulkan device" | ||
printVersion :: IO () | ||
printVersion = putStrLn $ "Seangine" <> " " <> showVersion version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
module Graphics.Seangine (SeangineCli (..)) where | ||
module Graphics.Seangine | ||
( SeangineOptions (..), | ||
runSeangine, | ||
) where | ||
|
||
data SeangineCli = SeangineCli | ||
data SeangineOptions = SeangineOptions | ||
{ optFile :: !FilePath, | ||
optDevice :: !(Maybe String), | ||
optDebug :: !Bool, | ||
optVersion :: !Bool | ||
optDebug :: !Bool | ||
} | ||
deriving (Eq) | ||
|
||
runSeangine :: SeangineOptions -> IO () | ||
runSeangine _ = pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module Graphics.Seangine.Types (SeangineOptions (..)) where | ||
|
||
data SeangineOptions = SeangineOptions | ||
{ optFile :: !FilePath, | ||
optDevice :: !(Maybe String), | ||
optDebug :: !Bool | ||
} | ||
deriving (Eq) |