Beispiel #1
0
 it("is called when first command is `help`", function () {
     spyOn(parser, "parse").andReturn({
         commands: ["help"],
         options: {}
     });
     cli.interpret(basicArgs.concat(["help"]));
     expect(help.call).toHaveBeenCalled();
 });
Beispiel #2
0
 it("can be passed a sub command to show help for", function () {
     spyOn(parser, "parse").andReturn({
         commands: ["help", "sub_command"],
         options: {}
     });
     cli.interpret(basicArgs.concat(["help", "sub_command"]));
     expect(help.call).toHaveBeenCalledWith("sub_command");
 });
Beispiel #3
0
 it("passes any given cli options to the command module", function () {
     spyOn(parser, "parse").andReturn({
         commands: ["proxy"],
         options: {"a": true}
     });
     cli.interpret(basicArgs.concat(["proxy", "--a"]));
     expect(proxy.call).toHaveBeenCalledWith({"a": true});
 });
Beispiel #4
0
 it("requires cli/command_name and uses the method named after the sub command, if given", function () {
     spyOn(parser, "parse").andReturn({
         commands: ["proxy", "start"],
         options: {"a": true}
     });
     cli.interpret(basicArgs.concat(["proxy", "start"]));
     expect(proxy.start).toHaveBeenCalledWith({"a": true});
 });
Beispiel #5
0
        it("logs general usage if there is an unknown command", function () {
            var unknownCmd = "unknown_foobar_command",
                unknownCmdMessage = ("Unknown command: " + unknownCmd).red.bold; // .red from colors package

            spyOn(parser, "parse").andReturn({
                commands: [unknownCmd],
                options: {}
            });

            cli.interpret(basicArgs.concat([unknownCmd]));

            expect(console.error).toHaveBeenCalledWith(unknownCmdMessage);
            expect(help.call).toHaveBeenCalledWith();
        });
Beispiel #6
0
 it("is called when no command", function () {
     spyOn(parser, "parse").andReturn({commands: [], options: {}});
     cli.interpret(basicArgs);
     expect(help.call).toHaveBeenCalled();
 });
Beispiel #7
0
 it("requires cli/command_name and uses the `call` method if no subcommand is given", function () {
     spyOn(parser, "parse").andReturn({commands: ["proxy"], options: {}});
     cli.interpret(basicArgs.concat(["proxy"]));
     expect(proxy.call).toHaveBeenCalled();
 });