diff --git a/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs b/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs index 42e9619d9482..cc3e1373f8e4 100644 --- a/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs +++ b/daml-assistant/daml-helper/src/DA/Daml/Helper/Main.hs @@ -44,6 +44,9 @@ data Command , jsonApiCfg :: JsonApiConfig , onStartM :: Maybe String , waitForSignal :: WaitForSignal + , sandboxOptions :: SandboxOptions + , navigatorOptions :: NavigatorOptions + , jsonApiOptions :: JsonApiOptions } | Deploy { flags :: HostAndPortFlags } | LedgerListParties { flags :: HostAndPortFlags, json :: JsonFlag } @@ -106,6 +109,9 @@ commandParser = subparser $ fold <*> jsonApiCfg <*> optional (option str (long "on-start" <> metavar "COMMAND" <> help "Command to run once sandbox and navigator are running.")) <*> (WaitForSignal <$> flagYesNoAuto "wait-for-signal" True "Wait for Ctrl+C or interrupt after starting servers." idm) + <*> (SandboxOptions <$> many (strOption (long "sandbox-option" <> metavar "SANDBOX_OPTION" <> help "Pass option to sandbox"))) + <*> (NavigatorOptions <$> many (strOption (long "navigator-option" <> metavar "NAVIGATOR_OPTION" <> help "Pass option to navigator"))) + <*> (JsonApiOptions <$> many (strOption (long "json-api-option" <> metavar "JSON_API_OPTION" <> help "Pass option to HTTP JSON API"))) deployCmdInfo = mconcat [ progDesc $ concat @@ -215,7 +221,17 @@ runCommand New {..} = runNew targetFolder templateNameM [] runCommand Migrate {..} = runMigrate targetFolder pkgPathFrom pkgPathTo runCommand Init {..} = runInit targetFolderM runCommand ListTemplates = runListTemplates -runCommand Start {..} = runStart sandboxPortM startNavigator jsonApiCfg openBrowser onStartM waitForSignal +runCommand Start {..} = + runStart + sandboxPortM + startNavigator + jsonApiCfg + openBrowser + onStartM + waitForSignal + sandboxOptions + navigatorOptions + jsonApiOptions runCommand Deploy {..} = runDeploy flags runCommand LedgerListParties {..} = runLedgerListParties flags json runCommand LedgerAllocateParties {..} = runLedgerAllocateParties flags parties diff --git a/daml-assistant/daml-helper/src/DA/Daml/Helper/Run.hs b/daml-assistant/daml-helper/src/DA/Daml/Helper/Run.hs index e850f49ef750..1a412ccf573e 100644 --- a/daml-assistant/daml-helper/src/DA/Daml/Helper/Run.hs +++ b/daml-assistant/daml-helper/src/DA/Daml/Helper/Run.hs @@ -35,6 +35,9 @@ module DA.Daml.Helper.Run , StartNavigator(..) , WaitForSignal(..) , DamlHelperError(..) + , SandboxOptions(..) + , NavigatorOptions(..) + , JsonApiOptions(..) ) where import Control.Concurrent @@ -728,8 +731,32 @@ data JsonApiConfig = JsonApiConfig -- | Whether `daml start` should wait for Ctrl+C or interrupt after starting servers. newtype WaitForSignal = WaitForSignal Bool -runStart :: Maybe SandboxPort -> StartNavigator -> JsonApiConfig -> OpenBrowser -> Maybe String -> WaitForSignal -> IO () -runStart sandboxPortM (StartNavigator shouldStartNavigator) (JsonApiConfig mbJsonApiPort) (OpenBrowser shouldOpenBrowser) onStartM (WaitForSignal shouldWaitForSignal) = withProjectRoot Nothing (ProjectCheck "daml start" True) $ \_ _ -> do +newtype SandboxOptions = SandboxOptions [String] +newtype NavigatorOptions = NavigatorOptions [String] +newtype JsonApiOptions = JsonApiOptions [String] + +runStart + :: Maybe SandboxPort + -> StartNavigator + -> JsonApiConfig + -> OpenBrowser + -> Maybe String + -> WaitForSignal + -> SandboxOptions + -> NavigatorOptions + -> JsonApiOptions + -> IO () +runStart + sandboxPortM + (StartNavigator shouldStartNavigator) + (JsonApiConfig mbJsonApiPort) + (OpenBrowser shouldOpenBrowser) + onStartM + (WaitForSignal shouldWaitForSignal) + (SandboxOptions sandboxOpts) + (NavigatorOptions navigatorOpts) + (JsonApiOptions jsonApiOpts) + = withProjectRoot Nothing (ProjectCheck "daml start" True) $ \_ _ -> do let sandboxPort = fromMaybe defaultSandboxPort sandboxPortM projectConfig <- getProjectConfig darPath <- getDarPath @@ -738,12 +765,12 @@ runStart sandboxPortM (StartNavigator shouldStartNavigator) (JsonApiConfig mbJso queryProjectConfig ["scenario"] projectConfig doBuild let scenarioArgs = maybe [] (\scenario -> ["--scenario", scenario]) mbScenario - withSandbox sandboxPort (darPath : scenarioArgs) $ \sandboxPh -> do - withNavigator' sandboxPh sandboxPort navigatorPort [] $ \navigatorPh -> do + withSandbox sandboxPort (darPath : scenarioArgs ++ sandboxOpts) $ \sandboxPh -> do + withNavigator' sandboxPh sandboxPort navigatorPort navigatorOpts $ \navigatorPh -> do whenJust onStartM $ \onStart -> runProcess_ (shell onStart) when (shouldStartNavigator && shouldOpenBrowser) $ void $ openBrowser (navigatorURL navigatorPort) - withJsonApi' sandboxPh sandboxPort [] $ \jsonApiPh -> do + withJsonApi' sandboxPh sandboxPort jsonApiOpts $ \jsonApiPh -> do when shouldWaitForSignal $ void $ waitAnyCancel =<< mapM (async . waitExitCode) [navigatorPh,sandboxPh,jsonApiPh] diff --git a/docs/source/tools/assistant.rst b/docs/source/tools/assistant.rst index 0a768b65f127..21224c4f4cb8 100644 --- a/docs/source/tools/assistant.rst +++ b/docs/source/tools/assistant.rst @@ -19,6 +19,8 @@ DAML Assistant (``daml``) - Launch :doc:`DAML Studio `: ``daml studio`` - Launch :doc:`Sandbox `, :doc:`Navigator ` and the HTTP JSON API: ``daml start`` You can disable the HTTP JSON API by passing ``--json-api-port none`` to ``daml start``. + To specify additional options for sandbox/navigator/the HTTP JSON API you can use + ``--sandbox-option=opt``, ``--navigator-option=opt`` and ``--json-api-option=opt``. - Launch Sandbox: ``daml sandbox`` - Launch Navigator: ``daml navigator`` - Launch :doc:`Extractor `: ``daml extractor`` diff --git a/unreleased.rst b/unreleased.rst index dc9609937dd1..5814c85e45d2 100644 --- a/unreleased.rst +++ b/unreleased.rst @@ -9,3 +9,6 @@ This page contains release notes for the SDK. HEAD — ongoing -------------- +- [DAML Assistant] ``daml start`` now supports ``--sandbox-option=opt``, ``--navigator-option=opt`` + and ``--json-api-option=opt`` to pass additional option to sandbox/navigator/json-api. + These flags can be specified multiple times.