Command framework

This commit is contained in:
Daniel Kluge
2021-12-16 00:21:14 +01:00
parent ced2559551
commit ec595650fd
10 changed files with 183 additions and 15 deletions
+9 -3
View File
@@ -1,9 +1,15 @@
import { useCallback, useState } from "react";
import { useState } from "react";
import REPLInput from "./REPLInput";
import REPLHistory from "./REPLHistory";
const REPL = () => {
const [history, manipulateHistory] = useState([]);
return <REPLInput historyCallback={manipulateHistory} />;
const [history, manipulateHistory] = useState<string[]>([]);
const onCommandExecuted = (result: string[]) => manipulateHistory(result.reverse().concat(history).slice(0, 1000));
return (<>
<REPLHistory history={history} />
<REPLInput historyCallback={onCommandExecuted} />
</>);
};
export default REPL;