From eaa6b0b5f43738c0386e99eeba26b44250e6136d Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 5 Dec 2015 19:12:26 +0100 Subject: Implement `cd` command to enable changing _MetaTerm_'s working directory Exposing access to the working directory to QML is the first step towards enabling usage analogously to a normal terminal emulator alongside the management of multiple running appications. i.e. executing `cd` should change the global working directory so that consecutive commands work as expected. --- src/command/commands.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/command/commands.js b/src/command/commands.js index 732eb5b..2ec1bb6 100644 --- a/src/command/commands.js +++ b/src/command/commands.js @@ -114,3 +114,13 @@ function prev() { function q() { Qt.quit(); } + +function cd(output, path) { + if ( path.length > 0 ) { + if ( !workingDirectory.cd(path) ) { + output.error('\"' + path + '\" doesn\'t exist.'); + } + } else { + output.log(workingDirectory.current()); + } +} -- cgit v1.2.3