Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate showing help to the back end process. #13729

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@
"frontend": "lib/browser/window/browser-window-module",
"frontendElectron": "lib/electron-browser/window/electron-window-module"
},
{
"backendElectron": "lib/electron-node/cli/electron-backend-cli-module"
},
{
"frontend": "lib/browser/keyboard/browser-keyboard-module",
"frontendElectron": "lib/electron-browser/keyboard/electron-keyboard-module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ export class ElectronMainApplication {
async start(config: FrontendApplicationConfig): Promise<void> {
const argv = this.processArgv.getProcessArgvWithoutBin(process.argv);
createYargs(argv, process.cwd())
.help(false)
.command('$0 [file]', false,
cmd => cmd
.option('electronUserData', {
Expand Down
24 changes: 24 additions & 0 deletions packages/core/src/electron-node/cli/electron-backend-cli-module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// *****************************************************************************
// Copyright (C) 2024 STMicroelectronics and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************

import { ContainerModule } from 'inversify';
import { ElectronCliContribution } from './electron-cli-contribution';
import { CliContribution } from '../../node';

export default new ContainerModule(bind => {
bind(ElectronCliContribution).toSelf().inSingletonScope();
bind(CliContribution).toService(ElectronCliContribution);
});
35 changes: 35 additions & 0 deletions packages/core/src/electron-node/cli/electron-cli-contribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/********************************************************************************
* Copyright (C) 2024 STMicroelectronics and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
********************************************************************************/

import { injectable } from 'inversify';
import { Argv, Arguments } from 'yargs';
import { CliContribution } from '../../node';
import { MaybePromise } from '../../common';

@injectable()
export class ElectronCliContribution implements CliContribution {

configure(conf: Argv): void {
conf.option('electronUserData', {
type: 'string',
describe: 'The area where the electron main process puts its data'
});
}

setArguments(args: Arguments): MaybePromise<void> {
}

}
4 changes: 2 additions & 2 deletions packages/core/src/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class CliManager {
async initializeCli<T>(argv: string[], postSetArguments: () => Promise<void>, defaultCommand: () => Promise<void>): Promise<void> {
const pack = require('../../package.json');
const version = pack.version;
const command = yargs.version(version);
const command = yargs(argv, process.cwd()).version(version);
command.exitProcess(this.isExit());
for (const contrib of this.contributionsProvider.getContributions()) {
contrib.configure(command);
Expand All @@ -54,7 +54,7 @@ export class CliManager {
await postSetArguments();
})
.command('$0', false, () => { }, defaultCommand)
.parse(argv);
.parse();
}

protected isExit(): boolean {
Expand Down
Loading