Skip to content

Commit

Permalink
Add flag system with "sshfs.flags" config option
Browse files Browse the repository at this point in the history
  • Loading branch information
SchoofsKelvin committed Feb 11, 2021
1 parent 443026d commit 83d6cd0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
}
},
Expand Down
25 changes: 25 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 83d6cd0

Please sign in to comment.