mirror of
https://github.com/wavetermdev/inshellisense.git
synced 2026-08-05 13:43:30 -07:00
feat: add complete command (#78)
* feat: add complete command * refactor: get suggestion code Signed-off-by: Chapman Pendery <cpendery@vt.edu> --------- Signed-off-by: Chapman Pendery <cpendery@vt.edu> Co-authored-by: Chapman Pendery <cpendery@vt.edu>
This commit is contained in:
co-authored by
Chapman Pendery
parent
722ba9b06c
commit
e86193e57c
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { Command } from "commander";
|
||||
import { getSuggestions } from "../runtime/runtime.js";
|
||||
|
||||
const action = async (input: string) => {
|
||||
const suggestions = await getSuggestions(input);
|
||||
process.stdout.write(JSON.stringify(suggestions));
|
||||
};
|
||||
|
||||
const cmd = new Command("complete");
|
||||
cmd.description(`generates a completion for the provided input`);
|
||||
cmd.argument("<input>");
|
||||
cmd.action(action);
|
||||
|
||||
export default cmd;
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
import { Command } from "commander";
|
||||
|
||||
import complete from "./commands/complete.js";
|
||||
import uninstall from "./commands/uninstall.js";
|
||||
import { action, supportedShells } from "./commands/root.js";
|
||||
import { getVersion } from "./utils/version.js";
|
||||
@@ -21,6 +22,7 @@ program
|
||||
.option("-s, --shell <shell>", `shell to use for command execution, supported shells: ${supportedShells}`)
|
||||
.showHelpAfterError("(add --help for additional information)");
|
||||
|
||||
program.addCommand(complete);
|
||||
program.addCommand(uninstall);
|
||||
|
||||
program.parse();
|
||||
|
||||
Reference in New Issue
Block a user