-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.ts
More file actions
72 lines (65 loc) · 1.85 KB
/
index.ts
File metadata and controls
72 lines (65 loc) · 1.85 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { Command } from 'commander'
import { logError } from '../../lib/util/error.js'
import { createConfiguration } from './create.js'
import { showConfigurationPath } from './path.js'
import { removeConfiguration } from './remove.js'
import { runConfiguration, runConfigurationByName } from './run.js'
import { showConfiguration } from './show.js'
export async function addConfigurationsCommands(program: Command) {
const configurations = new Command('configurations')
configurations.description('create and run SQL auth proxy configurations')
configurations
.command('create')
.alias('edit')
.description('create or edit Cloud SQL Auth Proxy configuration')
.action(async () => {
try {
await createConfiguration()
} catch (error) {
logError(error)
}
})
configurations
.command('show')
.description('show Cloud SQL Auth Proxy configuration')
.action(async () => {
try {
await showConfiguration()
} catch (error) {
logError(error)
}
})
configurations
.command('remove')
.alias('rm')
.description('remove Cloud SQL Auth Proxy configuration')
.action(async () => {
try {
await removeConfiguration()
} catch (error) {
logError(error)
}
})
configurations
.command('run')
.argument('[name]', 'configuration name, optional')
.description('run Cloud SQL Auth Proxy configuration')
.action(async (name?: string) => {
try {
if (name) {
runConfigurationByName(name)
} else {
await runConfiguration()
}
} catch (error) {
logError(error)
}
})
configurations
.command('path')
.description('show path to local configurations file')
.action(() => {
showConfigurationPath()
})
program.addCommand(configurations)
}