Subnet command (#17)

* Started working on subnets

* Basic version of the subnet command

* Improved subnet command

* almost done with subnets

* improve positioning
This commit is contained in:
Borys Levytskyi
2021-01-16 11:33:45 +02:00
committed by GitHub
parent 0cd9c8049b
commit 478ecbfb60
24 changed files with 659 additions and 332 deletions

View File

@@ -7,6 +7,7 @@ import ErrorResultView from './components/ErrorResultView';
import HelpResultView from './components/HelpResultView';
import TextResultView from './components/TextResultView';
import WhatsnewResultView from './components/WhatsNewResultView';
import {STARTUP_COMMAND_KEY} from './startup';
const shellModule = {
setup: function(appState: AppState, cmd: CmdShell) {
@@ -29,6 +30,35 @@ const shellModule = {
appState.addCommandResult(c.input, <TextResultView text={`Debug Mode: ${appState.debugMode}`}/>);
});
if(appState.env !== 'prod') {
// Default command for development purposes
cmd.command({
canHandle: (s: string) => s.indexOf('default') === 0,
handle: (s: CommandInput) => {
const executeCommand = (c: string) => {
console.log(c);
if(c.length === 0) {
return "Default comand: " + localStorage.getItem(STARTUP_COMMAND_KEY);
}
else if(c === 'clear') {
localStorage.removeItem(STARTUP_COMMAND_KEY);
return "Default startup command cleared";
}
localStorage.setItem(STARTUP_COMMAND_KEY, c);
return `Default startup command saved: ${c}`;
};
const command = s.input.substring(7).trim();
const result = executeCommand(command);
appState.addCommandResult(s.input, <TextResultView text={result} />);
}
});
};
cmd.onError((input: string, err: Error) => appState.addCommandResult(input, <ErrorResultView errorMessage={err.toString()} />));
}
}