MCPcopy Create free account
hub / github.com/Borvik/vscode-postgres / run

Method run

src/commands/addConnection.ts:32–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30 readonly TotalSteps: number = 7;
31
32 async run() {
33 const state = {port: 5432} as Partial<ConnectionState>;
34 if (!(await MultiStepInput.run(input => this.setHostName(input, state)))) {
35 // command cancelled
36 return;
37 }
38
39 // create the db connection
40 const tree = PostgreSQLTreeDataProvider.getInstance();
41
42 let connections = tree.context.globalState.get<{ [key: string]: IConnection }>(Constants.GlobalStateKey);
43 if (!connections) connections = {};
44
45 const id = uuidv1();
46 connections[id] = {
47 label: state.label,
48 host: state.host,
49 user: state.user,
50 port: state.port,
51 ssl: state.secure,
52 database: state.database
53 };
54
55 connections[id].hasPassword = !!state.password;
56 if (connections[id].hasPassword) {
57 await Global.context.secrets.store(id, state.password);
58 }
59
60 await tree.context.globalState.update(Constants.GlobalStateKey, connections);
61 tree.refresh();
62 }
63
64 async setHostName(input: MultiStepInput, state: Partial<ConnectionState>) {
65 state.host = await input.showInputBox({

Callers

nothing calls this directly

Calls 4

setHostNameMethod · 0.95
updateMethod · 0.80
getInstanceMethod · 0.45
refreshMethod · 0.45

Tested by

no test coverage detected