fix: configuration proper scope, catch missing val

This commit is contained in:
əlemi 2024-09-06 16:04:24 +02:00
parent cc5bd6ea16
commit bce44730b9
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 32 additions and 25 deletions

View file

@ -62,25 +62,23 @@
"title": "Hello World (debug)"
}
],
"contributes": {
"configuration": {
"title": "codemp",
"properties": {
"typescript.server": {
"type": "string",
"default": "http://codemp.dev:50053",
"description": "Server address to connect to"
},
"typescript.username": {
"type": "string",
"default": "mail@example.net",
"description": "Username to use for login (the email you used during registration)"
},
"typescript.password": {
"type": "string",
"default": "dont-use-this-password",
"description": "Password to use for login"
}
"configuration": {
"title": "codemp",
"properties": {
"codemp.server": {
"type": "string",
"default": "http://codemp.dev:50053",
"description": "Server address to connect to"
},
"codemp.username": {
"type": "string",
"default": "",
"description": "Username to use for login (the email you used during registration)"
},
"codemp.password": {
"type": "string",
"default": "",
"description": "Password to use for login"
}
}
}
@ -102,6 +100,7 @@
"@typescript-eslint/eslint-plugin": "^6.4.1",
"@typescript-eslint/parser": "^6.4.1",
"@vscode/test-electron": "^2.3.4",
"@vscode/vsce": "^3.1.0",
"eslint": "^8.47.0",
"glob": "^10.3.3",
"mocha": "^10.2.0",
@ -109,7 +108,6 @@
"typescript": "^5.1.6"
},
"dependencies": {
"codemp": "^0.0.5",
"vsce": "^2.15.0"
"codemp": "^0.0.5"
}
}

View file

@ -10,10 +10,19 @@ let workspace: codemp.Workspace | null = null;
let mine : boolean;
export async function connect() {
let config = vscode.workspace.getConfiguration('codemp-vscode');
let server : string = config.get("server", "http://codemp.dev:50053");
let username : string = config.get("username")!;
let password : string = config.get("password")!;
let config = vscode.workspace.getConfiguration('codemp');
let server = config.get<string>("server", "http://codemp.dev:50053");
let username = config.get<string>("username");
if (!username) {
return vscode.window.showErrorMessage("missing username in settings: configure it first!");
}
let password = config.get<string>("password");
if (!password) {
return vscode.window.showErrorMessage("missing password in settings: configure it first!");
}
client = await codemp.connect(server, username, password);
}