Commit a0147a94 authored by Jakob Moser's avatar Jakob Moser
Browse files

Add clear() API

parent 8ee0947b
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -132,6 +132,9 @@ class ExerciseExecutionContext {
     * By default, after running the provided command, "clear" is
     * executed to clear the terminal. If you do not want to clear the
     * terminal, set `keepVisible` to true.
     * 
     * If no command is provided (i.e. command === null), no command is executed.
     * This is helpful if you just want to clear the terminal at the start of an exercise.
     * @param {string} command
     * @param {boolean} keepVisible
     */
@@ -140,7 +143,9 @@ class ExerciseExecutionContext {

            function prepareAndResolve() {
                // Actually prepare and resolve the promise (we get the resolve() function via the closure)
                if(command !== null) {
                    runCommand(command)
                }
                if (!keepVisible) {
                    runCommand("clear")
                }
@@ -163,6 +168,13 @@ class ExerciseExecutionContext {
        })
    }

    /**
     * Clear the terminal. Shorthand for prepareWith(null, true)
     */
    clear() {
        this.prepareWith(null, true)
    }

    /**
     * Indicates that manual confirmation is needed. Used like this:
     *