refactor: simplify main, address reReadConfig TODO
This commit is contained in:
+6
-12
@@ -36,18 +36,12 @@ main installSignalHandlers runAppWithSocket CLI{cliCommand, cliPath} = do
|
|||||||
conf@AppConfig{..} <-
|
conf@AppConfig{..} <-
|
||||||
either panic identity <$> Config.readAppConfig mempty cliPath Nothing
|
either panic identity <$> Config.readAppConfig mempty cliPath Nothing
|
||||||
appState <- AppState.init conf
|
appState <- AppState.init conf
|
||||||
|
case cliCommand of
|
||||||
-- Override the config with config options from the db
|
CmdDumpConfig -> do
|
||||||
-- TODO: the same operation is repeated on connectionWorker, ideally this
|
when configDbConfig $ reReadConfig True appState
|
||||||
-- would be done only once, but dump CmdDumpConfig needs it for tests.
|
putStr . Config.toText =<< AppState.getConfig appState
|
||||||
when configDbConfig $ reReadConfig True appState
|
CmdDumpSchema -> putStrLn =<< dumpSchema appState
|
||||||
|
CmdRun -> App.run installSignalHandlers runAppWithSocket appState
|
||||||
exec cliCommand appState
|
|
||||||
where
|
|
||||||
exec :: Command -> AppState -> IO ()
|
|
||||||
exec CmdDumpConfig appState = putStr . Config.toText =<< AppState.getConfig appState
|
|
||||||
exec CmdDumpSchema appState = putStrLn =<< dumpSchema appState
|
|
||||||
exec CmdRun appState = App.run installSignalHandlers runAppWithSocket appState
|
|
||||||
|
|
||||||
-- | Dump DbStructure schema to JSON
|
-- | Dump DbStructure schema to JSON
|
||||||
dumpSchema :: AppState -> IO LBS.ByteString
|
dumpSchema :: AppState -> IO LBS.ByteString
|
||||||
|
|||||||
Reference in New Issue
Block a user