diff --git a/src/app/cmd.js b/src/app/cmd.js index 27f797f..4670b61 100644 --- a/src/app/cmd.js +++ b/src/app/cmd.js @@ -55,8 +55,7 @@ var cmd = { }; function displayCommandError(input, message) { - var error = new app.models.ErrorResult(message); - cmdController.display(new app.models.DisplayResult(input, error)); + console.error('[displayCommandError] not implemented'); } function invokeHandler (input, handler) { diff --git a/src/app/commands.js b/src/app/commands.js index ea955ba..9350227 100644 --- a/src/app/commands.js +++ b/src/app/commands.js @@ -1,5 +1,6 @@ import appState from './appState'; import HelpResult from './models/HelpResult'; +import UnknownCommandResult from './models/UnknownCommandResult'; var cmdConfig = {}; @@ -41,5 +42,10 @@ export default { }, '-notrack': function () {} }); + + cmd.command({ + canHandle: () => true, + handle: (c) => appState.addCommandResult(new UnknownCommandResult(c.input)) + }) } } \ No newline at end of file diff --git a/src/app/components/AppRoot.jsx b/src/app/components/AppRoot.jsx index 7614486..5a0d4c2 100644 --- a/src/app/components/AppRoot.jsx +++ b/src/app/components/AppRoot.jsx @@ -12,7 +12,7 @@ export default class AppRoot extends React.Component { this.setState(this.props.appState); } render() { - var results = this.state.commandResults.map((r, i) => ); + var results = this.state.commandResults.map((r, i) => ); return

BitwiseCmd

diff --git a/src/app/components/results/DisplayResultView.jsx b/src/app/components/results/DisplayResultView.jsx index 315ff06..aa17ae5 100644 --- a/src/app/components/results/DisplayResultView.jsx +++ b/src/app/components/results/DisplayResultView.jsx @@ -1,9 +1,16 @@ import React from 'react'; import HelpResultView from './HelpResultView'; import HelpResult from '../../models/HelpResult'; +import UnknownCommandResult from '../../models/UnknownCommandResult'; + export default class DisplayResult extends React.Component { render() { + + if(this.props.content instanceof UnknownCommandResult) { + return this.renderUnknown(); + } + return
>{this.props.content.input}#
@@ -12,6 +19,10 @@ export default class DisplayResult extends React.Component {
; } + renderUnknown() { + return
Sorry, i don't know what {this.props.input} is :(
+ } + findResultComponent(result, key) { if(result instanceof HelpResult) { return diff --git a/src/app/index.jsx b/src/app/index.jsx index b64715d..3761a37 100644 --- a/src/app/index.jsx +++ b/src/app/index.jsx @@ -9,6 +9,7 @@ import AppRoot from './components/AppRoot'; commands.initialize(cmd); cmd.execute('help'); +cmd.execute('bluh'); var root = ; ReactDOM.render(root, document.getElementById('root')); \ No newline at end of file diff --git a/src/app/models/CommandResult.js b/src/app/models/CommandResult.js index b5f5a6a..a47fa2c 100644 --- a/src/app/models/CommandResult.js +++ b/src/app/models/CommandResult.js @@ -1,5 +1,10 @@ export default class CommandResult { constructor(input) { this.input = input; + this.inputHash = this.encodeHash(input); + } + + encodeHash (string) { + return encodeURI(string.trim().replace(/\s/g,',')); } } \ No newline at end of file diff --git a/src/app/models/UnknownCommandResult.js b/src/app/models/UnknownCommandResult.js new file mode 100644 index 0000000..5ce563e --- /dev/null +++ b/src/app/models/UnknownCommandResult.js @@ -0,0 +1,8 @@ +import CommandResult from './CommandResult'; + +export default class UnknownCommandResult extends CommandResult { + constructor(input) { + super(input); + this.message = `Sorry, i don''t know what ${input} is :(`; + } +} \ No newline at end of file