feat(xo-cli): improve no server message

This commit is contained in:
Julien Fontanet
2023-01-23 09:31:01 +01:00
parent 4f31b7007a
commit bfbfb9379a
2 changed files with 7 additions and 6 deletions

View File

@@ -8,9 +8,9 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it”
- [REST API] Expose `residentVms` property on hosts objects
- [VM/Advanced] Clarify *Windows Update* label [#6628](https://github.com/vatesfr/xen-orchestra/issues/6628) (PR [#6632](https://github.com/vatesfr/xen-orchestra/pull/6632))
- [VM/Advanced] Clarify _Windows Update_ label [#6628](https://github.com/vatesfr/xen-orchestra/issues/6628) (PR [#6632](https://github.com/vatesfr/xen-orchestra/pull/6632))
- [REST API] Add support to destroy VMs and VDIs
- [VM/Advanced] Add configuration flag for *Viridian* platform [#6572](https://github.com/vatesfr/xen-orchestra/issues/6572) (PR [#6631](https://github.com/vatesfr/xen-orchestra/pull/6631))
- [VM/Advanced] Add configuration flag for _Viridian_ platform [#6572](https://github.com/vatesfr/xen-orchestra/issues/6572) (PR [#6631](https://github.com/vatesfr/xen-orchestra/pull/6631))
- [Licenses] Makes `id` and `boundObjectId` copyable (PR [#6634](https://github.com/vatesfr/xen-orchestra/pull/6634))
### Bug fixes
@@ -44,6 +44,7 @@
- @xen-orchestra/mixins feat
- @xen-orchestra/xapi patch
- vhd-lib patch
- xo-cli patch
- xo-server minor
- xo-server-perf-alert patch
- xo-web minor

View File

@@ -32,7 +32,8 @@ const Xo = XoLib.default
async function connect() {
const { allowUnauthorized, server, token } = await config.load()
if (server === undefined) {
throw new Error('no server to connect to!')
const errorMessage = 'Please use `xo-cli --register` to associate with an XO instance first.\n\n' + help()
throw errorMessage
}
if (token === undefined) {
@@ -228,8 +229,7 @@ const help = wrap(
$name <command> [<name>=<value>]...
Executes a command on the current XO instance.
$name v$version
`.replace(/<([^>]+)>|\$(\w+)/g, function (_, arg, key) {
$name v$version`.replace(/<([^>]+)>|\$(\w+)/g, function (_, arg, key) {
if (arg) {
return '<' + chalk.yellow(arg) + '>'
}
@@ -285,7 +285,7 @@ async function main(args) {
// correctly displayed by `exec-promise`.
//
// Extracts the original error for a better display.
throw 'error' in error ? error.error : error
throw typeof error === 'object' && 'error' in error ? error.error : error
}
}