Skip to content

Commit

Permalink
Add dashboard:open command (#656)
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoliy Bazko <abazko@redhat.com>
  • Loading branch information
tolusha authored Apr 22, 2020
1 parent 25334f5 commit 941b5e4
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ USAGE
# Commands
<!-- 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)
Expand Down Expand Up @@ -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...)
Expand Down
47 changes: 47 additions & 0 deletions src/commands/dashboard/open.ts
Original file line number Diff line number Diff line change
@@ -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)
}
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 941b5e4

Please sign in to comment.