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

feat: Add dashboard:open command #656

Merged
merged 1 commit into from
Apr 22, 2020
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
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