forked from fauna/fauna-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist-endpoints.js
More file actions
44 lines (39 loc) · 1.25 KB
/
Copy pathlist-endpoints.js
File metadata and controls
44 lines (39 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const { loadEndpoints, errorOut } = require('../lib/misc.js')
const FaunaCommand = require('../lib/fauna-command.js')
class ListEndpointsCommand extends FaunaCommand {
async run() {
const log = this.log
return loadEndpoints()
.then(function (endpoints) {
var keys = Object.keys(endpoints)
if (keys.length === 0) {
throw new Error(
'No endpoints defined.\nSee fauna add-endpoint --help for more details.'
)
} else {
keys.forEach(function (endpoint) {
// skip the key that stores the default endpoint
if (endpoint === 'default') {
// in JS return skips this iteration.
return
}
var enabled = ''
if (endpoint === endpoints.default) {
enabled = ' *'
}
log(`${endpoint}${enabled}`)
})
}
})
.catch(function (err) {
errorOut(err.message, 1)
})
}
}
ListEndpointsCommand.description = `
Lists FaunaDB connection endpoints
`
ListEndpointsCommand.examples = ['$ fauna list-endpoints']
// clear the default FaunaCommand flags that accept --host, --port, etc.
ListEndpointsCommand.flags = {}
module.exports = ListEndpointsCommand