Add flag system with "sshfs.flags" config option

feature/ssh-config
Kelvin Schoofs 4 years ago
parent 443026df7a
commit 83d6cd0396

@ -290,6 +290,13 @@
"password": "CorrectHorseBatteryStaple"
}
]
},
"sshfs.flags": {
"title": "List of special flags to enable/disable certain fixes/features",
"description": "Flags are usually used for issues or beta testing. Flags can disappear/change anytime!",
"type": "array",
"items": "string",
"default": []
}
}
},

@ -326,3 +326,28 @@ vscode.workspace.onDidChangeConfiguration(async (e) => {
return loadConfigs();
});
loadConfigs();
/**
* Checks the `sshfs.flags` config (overridable by e.g. workspace settings).
* - Flags are case-insensitive
* - If a flag appears twice, the first mention of it is used
* - If a flag appears as "NAME", `null` is returned
* - If a flag appears as "FLAG=VALUE", `VALUE` is returned as a string
* - If a flag is missing, `undefined` is returned (different from `null`!)
* @param target The name of the flag to look for
*/
export function getFlag(target: string): string | null | undefined {
target = target.toLowerCase();
const flags: string[] = vscode.workspace.getConfiguration('sshfs').get('flags') || [];
for (const flag of flags) {
let name: string = flag;
let value: any = null;
const eq = flag.indexOf('=');
if (eq !== -1) {
name = flag.substring(0, eq);
value = flag.substring(eq + 1);
}
if (name.toLowerCase() === target) return value;
}
return undefined;
}

Loading…
Cancel
Save