From 35d4620a73842a4c2d133e0f9fda35cdfe527447 Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Tue, 21 Apr 2020 11:00:34 +0300 Subject: [PATCH] Add dashboard:open command Signed-off-by: Anatoliy Bazko --- README.md | 18 +++++++++++++ src/commands/dashboard/open.ts | 47 ++++++++++++++++++++++++++++++++++ yarn.lock | 2 +- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/commands/dashboard/open.ts diff --git a/README.md b/README.md index 36d39b2ce..ed0c51df6 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ USAGE # Commands * [`chectl autocomplete [SHELL]`](#chectl-autocomplete-shell) +* [`chectl dashboard:open`](#chectl-dashboardopen) * [`chectl devfile:generate`](#chectl-devfilegenerate) * [`chectl help [COMMAND]`](#chectl-help-command) * [`chectl server:debug`](#chectl-serverdebug) @@ -122,6 +123,23 @@ EXAMPLES _See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v0.1.5/src/commands/autocomplete/index.ts)_ +## `chectl dashboard:open` + +Open Eclipse Che dashboard + +``` +USAGE + $ chectl dashboard:open + +OPTIONS + -h, --help show CLI help + + -n, --chenamespace=chenamespace [default: che] Kubernetes namespace where Eclipse Che server is supposed to be + deployed +``` + +_See code: [src/commands/dashboard/open.ts](https://github.com/che-incubator/chectl/blob/v0.0.2/src/commands/dashboard/open.ts)_ + ## `chectl devfile:generate` generate and print a devfile to stdout given some Kubernetes resources and other workspaces features (project, language-support, commands etc...) diff --git a/src/commands/dashboard/open.ts b/src/commands/dashboard/open.ts new file mode 100644 index 000000000..6acb8b68b --- /dev/null +++ b/src/commands/dashboard/open.ts @@ -0,0 +1,47 @@ +/********************************************************************* + * Copyright (c) 2019 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ + +import { Command, flags } from '@oclif/command' +import { cli } from 'cli-ux' +import * as notifier from 'node-notifier' + +import { CheHelper } from '../../api/che' +import { cheNamespace } from '../../common-flags' + +export default class Open extends Command { + static description = 'Open Eclipse Che dashboard' + + static flags = { + help: flags.help({ char: 'h' }), + chenamespace: cheNamespace, + } + + async run() { + const { flags } = this.parse(Open) + + try { + const cheHelper = new CheHelper(flags) + const cheURL = await cheHelper.cheURL(flags.chenamespace) + const dashboardUrl = `${cheURL}/dashboard/` + + cli.info(`Opening ... ${dashboardUrl}`) + await cli.open(dashboardUrl) + } catch (error) { + this.error(error) + } + + notifier.notify({ + title: 'chectl', + message: 'Command dashboard:open has completed successfully.' + }) + + this.exit(0) + } +} diff --git a/yarn.lock b/yarn.lock index b6dd8b79a..caac63094 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1525,7 +1525,7 @@ ecc-jsbn@~0.1.1: "eclipse-che@git://github.com/eclipse/che#master": version "0.0.0" - resolved "git://github.com/eclipse/che#eb9a2ab9b616ae82c790dfa78116d45fed63d954" + resolved "git://github.com/eclipse/che#bf62877c12ae1cbc0174bd42a683e6151a46d48e" editorconfig@^0.15.0: version "0.15.3"