import React from 'react' ; import { History } from '../interfaces/history' ; import * as bin from './bin' ; export const shell = async ( history , command , setHistory , clearHistory , setCommand ) => { const args = command . split ( ' ' ) ; if ( command === 'clear' ) { clearHistory ( ) ; } else if ( command === '' ) { setHistory ( '' ) ; } else if ( Object . keys ( bin ) . indexOf ( args [ 0 ] ) === - 1 ) { setHistory ( `shell: command not found: ${ args [ 0 ] }. Try 'help' to get started.` ) ; } else { const output = await bin [ args [ 0 ] ] ( args . slice ( 1 ) ) ; setHistory ( output ) ; } setCommand ( '' ) ; } ;