How to use the pilot/types.Status.INVALID function in pilot

To help you get started, we’ve selected a few pilot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github atom / atom / vendor / pilot / canon.js View on Github external
/**
     * Executes the command and ensures request.done is called on the request in 
     * case it's not marked to be done already or async.
     */
    function execute() {
        command.exec(env, request.args, request);
        
        // If the request isn't asnync and isn't done, then make it done.
        if (!request.isAsync && !request.isDone) {
            request.done();
        }
    }
    
    
    if (request.getStatus() == Status.INVALID) {
        console.error("Canon.exec: Invalid parameter(s) passed to " + 
                            command.name);
        return false;   
    } 
    // If the request isn't complete yet, try to complete it.
    else if (request.getStatus() == Status.INCOMPLETE) {
        // Check if the sender has a ArgsProvider, otherwise use the default
        // build in one.
        var argsProvider;
        var senderObj = env[sender];
        if (!senderObj || !senderObj.getArgsProvider ||
            !(argsProvider = senderObj.getArgsProvider())) 
        {
            argsProvider = defaultArgsProvider;
        }
github pythonanywhere / dirigible-spreadsheet / static / ace / cockpit-uncompressed.js View on Github external
this.isUpdating = true;
        var input = {
            typed: this.element.value,
            cursor: {
                start: dom.getSelectionStart(this.element),
                end: dom.getSelectionEnd(this.element.selectionEnd)
            }
        };
        this.cli.update(input);

        var display = this.cli.getAssignmentAt(input.cursor.start).getHint();

        // 1. Update the completer with prompt/error marker/TAB info
        dom.removeCssClass(this.completer, Status.VALID.toString());
        dom.removeCssClass(this.completer, Status.INCOMPLETE.toString());
        dom.removeCssClass(this.completer, Status.INVALID.toString());

        var completion = '<span class="cptPrompt">&gt;</span> ';
        if (this.element.value.length &gt; 0) {
            var scores = this.cli.getInputStatusMarkup();
            completion += this.markupStatusScore(scores);
        }

        // Display the "-&gt; prediction" at the end of the completer
        if (this.element.value.length &gt; 0 &amp;&amp;
                display.predictions &amp;&amp; display.predictions.length &gt; 0) {
            var tab = display.predictions[0];
            completion += ' &nbsp;⇥ ' + (tab.name ? tab.name : tab);
        }
        this.completer.innerHTML = completion;
        dom.addCssClass(this.completer, this.cli.getWorstHint().status.toString());
github HelioNetworks / HelioPanel_archived / src / HelioNetworks / FileManagerBundle / Resources / public / js / ace / src / cockpit-uncompressed.js View on Github external
names.forEach(function(name) {
            var assignment = this.getAssignment(name);
            if (args.length === 0) {
                // No more values
                assignment.setValue(undefined); // i.e. default
            }
            else {
                var arg = args[0];
                args.splice(0, 1);
                assignment.setArgument(arg);
            }
        }, this);

        if (args.length > 0) {
            var remaining = Argument.merge(args);
            this._hints.push(new Hint(Status.INVALID,
                    'Input \'' + remaining.text + '\' makes no sense.',
                    remaining));
        }
    };
github atom / atom / vendor / pilot / canon.js View on Github external
return Status.VALID;
            } else {
                return Status.INCOMPLETE;   
            } 
        }
        
        // Check if the parameter value is valid.
        var reply,
            // The passed in value when parsing a type is a string.
            argsValue = args[param.name].toString();
        
        // Type.parse can throw errors. 
        try {
            reply = param.type.parse(argsValue);
        } catch (e) {
            return Status.INVALID;   
        }
        
        if (reply.status != Status.VALID) {
            return reply.status;   
        }
    } 
    // Check if the param is marked as required.
    else if (param.defaultValue === undefined) {
        // The parameter is not set on the args object but it's required,
        // which means, things are invalid.
        return Status.INCOMPLETE;
    }
    
    return Status.VALID;
}
github lisezmoi / modul.io / client / ace-0.1.6 / src / cockpit-uncompressed.js View on Github external
var predictions;

        // Non-valid conversions will have useful information to pass on
        if (this.conversion) {
            status = this.conversion.status;
            if (this.conversion.message) {
                message += this.conversion.message;
            }
            predictions = this.conversion.predictions;
        }

        // Hint if the param is required, but not provided
        var argProvided = this.arg &amp;&amp; this.arg.text !== '';
        var dataProvided = this.value !== undefined || argProvided;
        if (this.param.defaultValue === undefined &amp;&amp; !dataProvided) {
            status = Status.INVALID;
            message += '<strong>Required&lt;\strong&gt;';
        }

        return new Hint(status, message, start, end, predictions);
    },
</strong>
github qooxdoo / qooxdoo / qooxdoo / application / playground / source / resource / playground / editor / cockpit-uncompressed.js View on Github external
var predictions;

        // Non-valid conversions will have useful information to pass on
        if (this.conversion) {
            status = this.conversion.status;
            if (this.conversion.message) {
                message += this.conversion.message;
            }
            predictions = this.conversion.predictions;
        }

        // Hint if the param is required, but not provided
        var argProvided = this.arg &amp;&amp; this.arg.text !== '';
        var dataProvided = this.value !== undefined || argProvided;
        if (this.param.defaultValue === undefined &amp;&amp; !dataProvided) {
            status = Status.INVALID;
            message += '<strong>Required&lt;\strong&gt;';
        }

        return new Hint(status, message, start, end, predictions);
    },
</strong>
github ajaxorg / ace / plugins / cockpit / ui / cliView.js View on Github external
this.isUpdating = true;
        var input = {
            typed: this.element.value,
            cursor: {
                start: this.element.selectionStart,
                end: this.element.selectionEnd
            }
        };
        this.cli.update(input);

        var display = this.cli.getAssignmentAt(input.cursor.start).getHint();

        // 1. Update the completer with prompt/error marker/TAB info
        this.completer.classList.remove(Status.VALID.toString());
        this.completer.classList.remove(Status.INCOMPLETE.toString());
        this.completer.classList.remove(Status.INVALID.toString());
        // TODO: borked implementation? This is modern browser only. Fix
        // dom.removeCssClass(completer, Status.VALID.toString());
        // dom.removeCssClass(completer, Status.INCOMPLETE.toString());
        // dom.removeCssClass(completer, Status.INVALID.toString());

        var completion = '<span class="cptPrompt">&gt;</span> ';
        if (this.element.value.length &gt; 0) {
            var scores = this.cli.getInputStatusMarkup();
            completion += this.markupStatusScore(scores);
        }

        // Display the "-&gt; prediction" at the end of the completer
        if (this.element.value.length &gt; 0 &amp;&amp;
                display.predictions &amp;&amp; display.predictions.length &gt; 0) {
            var tab = display.predictions[0];
            completion += ' &nbsp;⇥ ' + (tab.name ? tab.name : tab);
github lisezmoi / modul.io / client / ace-0.1.6 / src / cockpit-uncompressed.js View on Github external
CliRequisition.prototype._assign = function(args) {
        if (args.length === 0) {
            this.setDefaultValues();
            return;
        }

        // Create an error if the command does not take parameters, but we have
        // been given them ...
        if (this.assignmentCount === 0) {
            // TODO: previously we were doing some extra work to avoid this if
            // we determined that we had args that were all whitespace, but
            // probably given our tighter tokenize() this won't be an issue?
            this._hints.push(new Hint(Status.INVALID,
                    this.commandAssignment.value.name +
                    ' does not take any parameters',
                    Argument.merge(args)));
            return;
        }

        // Special case: if there is only 1 parameter, and that's of type
        // text we put all the params into the first param
        if (this.assignmentCount === 1) {
            var assignment = this.getAssignment(0);
            if (assignment.param.type.name === 'text') {
                assignment.setArgument(Argument.merge(args));
                return;
            }
        }
github cloudjee / wavemaker / dev / studio / webapproot / app / lib / ace-build / support / cockpit / lib / cockpit / cli.js View on Github external
this._hints.forEach(function(hint) {
            var startInHint = c.start &gt;= hint.start &amp;&amp; c.start &lt;= hint.end;
            var endInHint = c.end &gt;= hint.start &amp;&amp; c.end &lt;= hint.end;
            var inHint = startInHint || endInHint;
            if (!inHint &amp;&amp; hint.status === Status.INCOMPLETE) {
                 hint.status = Status.INVALID;
            }
        }, this);
github ajaxorg / ace / plugins / cockpit / cli.js View on Github external
this._hints.forEach(function(hint) {
            var startInHint = c.start &gt;= hint.start &amp;&amp; c.start &lt;= hint.end;
            var endInHint = c.end &gt;= hint.start &amp;&amp; c.end &lt;= hint.end;
            var inHint = startInHint || endInHint;
            if (!inHint &amp;&amp; hint.status === Status.INCOMPLETE) {
                 hint.status = Status.INVALID;
            }
        }, this);