File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ import RIO.Process
55
66-- | Command line arguments
77data Options = Options
8- { optionsSummary :: ! Bool ,
8+ { optionsBinary :: ! Bool ,
9+ optionsSummary :: ! Bool ,
910 optionsVerbose :: ! Bool ,
1011 optionsFile :: FilePath
1112 }
@@ -29,6 +30,11 @@ instance HasProcessContext App where
2930instance HasOptions App where
3031 optionsL = lens appOptions (\ app opts -> app { appOptions = opts })
3132
33+ _optionsBinary :: Lens' Options Bool
34+ _optionsBinary = lens
35+ optionsBinary
36+ (\ opts bin -> opts { optionsBinary = bin })
37+
3238_optionsSummary :: Lens' Options Bool
3339_optionsSummary = lens
3440 optionsSummary
Original file line number Diff line number Diff line change @@ -13,11 +13,15 @@ run :: RIO App ()
1313run = do
1414 options <- asks (^. optionsL)
1515 let file = options ^. _optionsFile
16+ binary = options ^. _optionsBinary
1617 summary = options ^. _optionsSummary
1718 verbose = options ^. _optionsVerbose
19+ fromFile = if binary
20+ then fmap (over _Right (^. _gltf)) . fromBinaryFile
21+ else fromJsonFile
1822
1923 logInfo $ " File: " <> fromString file
20- result <- liftIO $ fromJsonFile file
24+ result <- liftIO $ fromFile file
2125
2226 either reportError (reporter verbose summary) result
2327
Original file line number Diff line number Diff line change @@ -40,10 +40,16 @@ runApp processContext cliOptions logOptions appAction
4040
4141options :: Parser Options
4242options = Options
43- <$> switch summaryOption
43+ <$> switch binaryOption
44+ <*> switch summaryOption
4445 <*> switch verboseOption
4546 <*> strArgument fileArg
4647
48+ binaryOption :: Mod FlagFields Bool
49+ binaryOption = long " binary"
50+ <> short ' b'
51+ <> help " Load file as GLB (Binary glTF)"
52+
4753summaryOption :: Mod FlagFields Bool
4854summaryOption
4955 = long " summary"
You can’t perform that action at this time.
0 commit comments