upgrade commands & console

develop
TBS093A 2020-07-22 16:12:17 +02:00
parent aca4eb0f2d
commit db4782acf0
2 changed files with 25 additions and 18 deletions

View File

@ -1,11 +1,12 @@
import React from 'react'
const help = () => {
return "register - register user by form \n"
+ "login - login user by form \n"
+ "logout - logout user \n"
+ "start - start command \n"
+ " -a --app - app flag - start music service app \n"
return "register - register user by form \n"
+ "login - login user by form \n"
+ "logout - logout user \n"
+ "start - start command \n"
+ " -a --app - app flag - start music service app \n"
+ "clean - clean screen \n"
}
const register = () => {
@ -41,11 +42,8 @@ const startApp = () => {
}
const undefined = (command) => {
return (
<div>
command '{command}' is undefined
</div>
)
return 'command "'+ command + '" is undefined\n'
+ ' type "help" for more commands\n'
}
export default {

View File

@ -22,26 +22,35 @@ const IndexConsole = () => {
const consoleInput = React.createRef()
let consoleUser = 'guest@00x097 * > '
const detectCommand = (event) => {
event.preventDefault()
setConsoleHistory( '# ' + consoleInput.current.value + '\n')
if (consoleInput.current.value === 'help')
setConsoleHistory( commands.help() )
console.log(consoleHistory)
let inputValue = consoleInput.current.value
consoleUser += inputValue + '\n'
if ( inputValue === 'help' )
setConsoleHistory( consoleHistory + consoleUser + commands.help() )
else if ( inputValue === 'clean' )
setConsoleHistory( '' )
else
setConsoleHistory( consoleHistory + consoleUser + commands.undefined(inputValue) )
consoleInput.current.value = ''
activateInput()
}
return (
<div id='consoleDiv' onClick={ activateInput }>
<div>
tbs093a@00x097 system, welcome <br />
type 'help' to get commands
<div id='consoleInfo'>
00x097 system (Version 0.1.9) <br />
type 'help' for more commands <br />
type 'start -a' for start app
<br /><br />
</div>
<pre id='consoleHistory'>
{ consoleHistory }
</pre>
<form onSubmit={ detectCommand }>
#
guest@00x097 * >
<input
id='consoleInput'
ref={consoleInput}