From a5c5762ddac95c827a72c021238b31bc06c821fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Wawrzyniec=20Urba=C5=84czyk?= Date: Thu, 29 Apr 2021 23:21:18 +0200 Subject: [PATCH] Passing options to backend and adding `--verbose` flag (#1531) ref #1525 --- CHANGELOG.md | 6 ++++++ build/run.js | 7 ++++--- src/js/lib/client/src/index.js | 23 ++++++++++++++++++++--- src/rust/ide/lib/args/src/lib.rs | 1 + 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 259f6e4242..ec9d70e2e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ - [Window management buttons.][1511]. The IDE now has components for "fullscreen" nad "close" buttons. They will be available only when running IDE in a cloud environment. +- [Customizable backend options][1531]. When invoking Enso IDE through command + line interface, it is possible to give `--` argument separator. All arguments + following the separator will be passed to the backend. +- [Added `--verbose` parameter][1531]. If `--verbose` is given as command line + argument, the IDE and the backend will produce more detailed logs.
![Bug Fixes](/docs/assets/tags/bug_fixes.svg) @@ -23,6 +28,7 @@ you can find their release notes [here](https://github.com/enso-org/enso/blob/main/RELEASES.md). [1511]: https://github.com/enso-org/ide/pull/1511 +[1531]: https://github.com/enso-org/ide/pull/1531
diff --git a/build/run.js b/build/run.js index 28b9cbd4a8..874541b9a6 100755 --- a/build/run.js +++ b/build/run.js @@ -206,9 +206,10 @@ commands.start.rust = async function(argv) { commands.start.js = async function (argv) { await installJsDeps() console.log(`Building JS target.` + argv) - const args = targetArgs.concat([ - `--backend-path ${paths.get_project_manager_path(paths.dist.bin)}`, - ]) + // The backend path is being prepended here, as appending would be incorrect. + // That is because `targetArgs` might include `-- …` and appended args could + // end up being passed to the spawned backend process. + const args = ['--backend-path', paths.get_project_manager_path(paths.dist.bin)].concat(targetArgs) if (argv.dev) { args.push('--dev') } await cmd.with_cwd(paths.js.root, async () => { await run('npm', ['run', 'start', '--'].concat(args)) diff --git a/src/js/lib/client/src/index.js b/src/js/lib/client/src/index.js index 19eb677224..c6a11d5aed 100644 --- a/src/js/lib/client/src/index.js +++ b/src/js/lib/client/src/index.js @@ -61,12 +61,17 @@ const execFile = util.promisify(child_process.execFile); let usage = ` ${pkg.build.productName} ${rootCfg.version} command line interface. -Usage: ${pkg.build.productName} [options] +Usage: ${pkg.build.productName} [options] [--] [backend args]... ` +let epilogue = ` +Arguments that follow the two dashes (\`--\`) will be passed to the backend process. They are used\ + if IDE spawns backend, i.e. if '--backend false' has not been set.` + let optParser = yargs .scriptName("") .usage(usage) + .epilogue(epilogue) .help() .version(false) .parserConfiguration({'populate--':true}) @@ -116,6 +121,13 @@ optParser.options('backend-path', { let debugOptionsGroup = 'Debug Options:' +optParser.options('verbose', { + group : debugOptionsGroup, + describe : `Increase logs verbosity. Affects both IDE and the backend.`, + default : false, + type : `boolean` +}) + optParser.options('entry-point', { group : debugOptionsGroup, describe : 'Run an alternative entry point (e.g. one of the debug scenes)', @@ -401,8 +413,12 @@ function spawnProjectManager(args) { function runBackend() { if(args.backend !== false) { - console.log("Starting the backend process.") - return spawnProjectManager() + let opts = args['--'] ? args['--'] : [] + if(args.verbose === true) { + opts.push('-vv') + } + console.log("Starting the backend process with the following options:", opts) + return spawnProjectManager(opts) } } @@ -504,6 +520,7 @@ function createWindow() { crash_report_host : args.crashReportHost, no_data_gathering : args.noDataGathering, node_labels : args.nodeLabels, + verbose : args.verbose, } if (args.project) { urlCfg.project = args.project } diff --git a/src/rust/ide/lib/args/src/lib.rs b/src/rust/ide/lib/args/src/lib.rs index 95fc55e61b..ace721d6ba 100644 --- a/src/rust/ide/lib/args/src/lib.rs +++ b/src/rust/ide/lib/args/src/lib.rs @@ -39,5 +39,6 @@ ensogl::read_args! { crash_report_host : String, no_data_gathering : bool, is_in_cloud : bool, + verbose : bool, } }