Skip to content

Commit

Permalink
merge: pull request #4 from henryhale/nxt
Browse files Browse the repository at this point in the history
Improve shell processes and their implementation.
  • Loading branch information
Henry Hale authored Apr 3, 2024
2 parents 20624c8 + 2c0d9c5 commit 076e143
Show file tree
Hide file tree
Showing 17 changed files with 1,833 additions and 1,987 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ This will generate the production-ready distribution files in the `dist` directo

## License

Copyright (c) 2023 [Henry Hale](https://github.com/henryhale).
Copyright (c) 2023-Present [Henry Hale](https://github.com/henryhale).

Released under the [MIT License](https://github.com/henryhale/viteshell/blob/master/LICENSE.txt).
25 changes: 17 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,22 @@ You need a terminal interface for inputting textual commands and outputting data
Below is a generic setup to register callback functions for output handling and shell termination.
```js
// triggered when outputting data
vsh.onoutput = (data) => {
/* print data */
};
// triggered when writing errors
vsh.onerror = (error) => {
/* print error */
};
// triggered when the `clear` command is issued
vsh.onclear = () => {
/* clear output display */
};
// triggered when the `exit` command is issued
vsh.onexit = () => {
/* cleanup */
};
Expand All @@ -335,9 +342,9 @@ const vsh = new ViteShell();
const output = document.querySelector("#output");
const input = document.querySelector("#input");
vsh.onoutput = (data) => (output.innerHTML += data);
vsh.onerror = (error) => (output.innerHTML += error);
vsh.onclear = () => (output.innerHTML = "");
vsh.onoutput = (data) => { output.innerHTML += data };
vsh.onerror = (error) => { output.innerHTML += error };
vsh.onclear = () => { output.innerHTML = "" };
input.onkeydown = (ev) => {
if (ev.key == "Enter") {
Expand All @@ -355,10 +362,10 @@ input.onkeydown = (ev) => {
Now activate the shell to prepare it for command execution with an optional _greeting or intro_ message.
```js
vsh.init("\nHello World!\n");
vsh.reset("\nHello World!\n");
```
The above line not only activates the shell but also prints the greeting message followed by the default prompt.
The above line not only resets or activates the shell but also prints the greeting message followed by the default prompt.
At this point, it should be working just well.
Expand All @@ -374,7 +381,9 @@ Since you have connected your shell to an input/output stream using [callbacks](
```js
const exec = async (input) => {
return await vsh.execute(input);
// ...
await vsh.execute(input);
// ...
};
exec('echo "Hello World!"');
Expand All @@ -384,7 +393,7 @@ exec('echo "Hello World!"');
Set an execution time limit beyond which the execution of a command is aborted.
**Example:** All commands must execute to completion in less than `5` seconds otherwise aborted.
**Example:** All commands must execute to completion in `5` seconds otherwise timed out(aborted).
```js
vsh.setExecutionTimeout(5);
Expand Down Expand Up @@ -431,6 +440,6 @@ The full public API for _viteshell_ is contained within the TypeScript [declarat
## License
Copyright (c) 2023 [Henry Hale](https://github.com/henryhale).
Copyright (c) 2023-Present [Henry Hale](https://github.com/henryhale).
Released under the [MIT License](https://github.com/henryhale/viteshell/blob/master/LICENSE.txt).
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,27 @@
},
"homepage": "https://github.com/henryhale/viteshell#readme",
"devDependencies": {
"@babel/core": "^7.23.6",
"@babel/preset-env": "^7.23.6",
"@babel/core": "^7.24.3",
"@babel/preset-env": "^7.24.3",
"@release-it/conventional-changelog": "^8.0.1",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-terser": "^0.4.4",
"@types/jest": "^29.5.11",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"@types/jest": "^29.5.12",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"babel-jest": "^29.7.0",
"eslint": "^8.56.0",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.3",
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.1.3",
"husky": "^9.0.11",
"jest": "^29.7.0",
"prettier": "^3.1.1",
"release-it": "^17.0.1",
"rollup": "^4.9.1",
"ts-jest": "^29.1.1",
"typescript": "^5.3.3"
"prettier": "^3.2.5",
"release-it": "^17.1.1",
"rollup": "^4.14.0",
"ts-jest": "^29.1.2",
"typescript": "^5.4.3"
},
"engines": {
"node": ">=14",
Expand Down
Loading

0 comments on commit 076e143

Please sign in to comment.