mirror of
https://github.com/wavetermdev/inshellisense.git
synced 2026-08-05 13:43:30 -07:00
feat: add cmd.exe support (#126)
* feat: add cmd.exe support Signed-off-by: Chapman Pendery <cpendery@vt.edu> * fix: add template to logging failure Signed-off-by: Chapman Pendery <cpendery@vt.edu> --------- Signed-off-by: Chapman Pendery <cpendery@vt.edu>
This commit is contained in:
@@ -49,6 +49,7 @@ inshellisense supports the following shells:
|
||||
- [fish](https://github.com/fish-shell/fish-shell)
|
||||
- [pwsh](https://github.com/PowerShell/PowerShell)
|
||||
- [powershell](https://learn.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-windows-powershell) (Windows Powershell)
|
||||
- [cmd](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd) _(experimental)_
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
+15
-9
@@ -2,6 +2,7 @@
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import fsAsync from "node:fs/promises";
|
||||
import log from "../utils/log.js";
|
||||
|
||||
const filepathsTemplate = async (cwd: string): Promise<Fig.Suggestion[]> => {
|
||||
const files = await fsAsync.readdir(cwd, { withFileTypes: true });
|
||||
@@ -28,15 +29,20 @@ export const runTemplates = async (template: Fig.TemplateStrings[] | Fig.Templat
|
||||
return (
|
||||
await Promise.all(
|
||||
templates.map(async (t) => {
|
||||
switch (t) {
|
||||
case "filepaths":
|
||||
return await filepathsTemplate(cwd);
|
||||
case "folders":
|
||||
return await foldersTemplate(cwd);
|
||||
case "history":
|
||||
return historyTemplate();
|
||||
case "help":
|
||||
return helpTemplate();
|
||||
try {
|
||||
switch (t) {
|
||||
case "filepaths":
|
||||
return await filepathsTemplate(cwd);
|
||||
case "folders":
|
||||
return await foldersTemplate(cwd);
|
||||
case "history":
|
||||
return historyTemplate();
|
||||
case "help":
|
||||
return helpTemplate();
|
||||
}
|
||||
} catch (e) {
|
||||
log.debug({ msg: "template failed", e, template: t, cwd });
|
||||
return [];
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
+8
-3
@@ -19,9 +19,14 @@ export enum Shell {
|
||||
Cmd = "cmd",
|
||||
}
|
||||
|
||||
export const supportedShells = [Shell.Bash, process.platform == "win32" ? Shell.Powershell : null, Shell.Pwsh, Shell.Zsh, Shell.Fish].filter(
|
||||
(shell) => shell != null,
|
||||
) as Shell[];
|
||||
export const supportedShells = [
|
||||
Shell.Bash,
|
||||
process.platform == "win32" ? Shell.Powershell : null,
|
||||
Shell.Pwsh,
|
||||
Shell.Zsh,
|
||||
Shell.Fish,
|
||||
process.platform == "win32" ? Shell.Cmd : null,
|
||||
].filter((shell) => shell != null) as Shell[];
|
||||
|
||||
export const userZdotdir = process.env?.ZDOTDIR ?? os.homedir() ?? `~`;
|
||||
export const zdotdir = path.join(os.tmpdir(), `is-zsh`);
|
||||
|
||||
Reference in New Issue
Block a user