https://github.com/dergoogler/cmdmodule
https://github.com/dergoogler/cmdmodule
Last synced: 31 minutes ago
JSON representation
- Host: GitHub
- URL: https://github.com/dergoogler/cmdmodule
- Owner: DerGoogler
- Created: 2022-07-30T12:29:01.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-18T20:45:55.000Z (almost 4 years ago)
- Last Synced: 2025-01-04T02:25:49.216Z (over 1 year ago)
- Language: TypeScript
- Size: 175 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CmdModule
TODO: Add description
> This library is in development, everything can CHANGE!
## Quickstart
```ts
import CmdModule, { css } from "cmdmodule";
const shell = new CmdModule({
prompt: css.array("", [css.fg.green`CLI`, "$ "]),
});
shell.on("echo", (self, args) => {
if (args.includes("--name")) {
return self.print(self.name);
}
return self.print(args[0]);
});
shell.on("arg", (self, args) => {
self.print(args.join(","));
});
shell.on(
"run",
(self, args) => {
shell.spawn("npm", ["run", args[0]], {
workingDirectory: "./",
});
},
{
disableReprompt: true,
}
);
shell.default(self => {
self.print(css.array(" ", [css.fg.red`${self.name}`, css.fg.yellow`command not found`]));
});
// Build the shell
shell.run();
```
> Run it by `npx ts-node cli.ts`