2.2.9 • Published 1 year ago

comqu v2.2.9

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

comqu

Features

  • Command Groups
  • Previous Trigger Memory
  • Customizable Input Screen Render
  • Loading Animation
  • Customizable Loading Message
  • Customizable Callbacks for Errors etc.
  • Async Command (while processing loading animation)
  • Key or Non-Key Parsing On Args (via regex)
  • Autocompletion on tab!

loading params example

Example

const { CLI } = require("comqu");

const cli = new CLI({ spinner: "dots" })
  .command({
    name: "test sub-cmd",
    description: "Test description",
    aliases: ["foo"],
    async onExecute({argStr, parsedArgs}) {
      console.log(`SUB CMD ARGS: "${argStr}"`);
    },
    options: []
  })
  .command({
    name: "test",
    description: "Test description",
    aliases: ["foo"],
    async onExecute({argStr, parsedArgs}) {
      console.log(`RAW ARGS: "${argStr}"`);
      console.log("Parsed", parsedArgs._)
    },
    options: [
      {
        name: "param1",
        required: true,
      },
      {
        name: "keyparam1",
        key: "hi",
        required: true,
      },
      {
        name: "param2",
        required: false,
      },
    ]
  })
  .command({
    name: "spinner",
    description: "spinner test",
    async onExecute() {
      await new Promise(r=>setTimeout(r, 1000));
      cli.loadingText = "Omg!";
      await new Promise(r=>setTimeout(r, 1000));
      cli.loadingText = "wow!";
      await new Promise(r=>setTimeout(r, 1000));
      cli.loadingText = "cool!";
      await new Promise(r=>setTimeout(r, 1000));
      cli.loadingText = "xd!";
      await new Promise(r=>setTimeout(r, 1000));
    },
  })
  .command({
    name: "exit",
    description: "exits the application",
    async onExecute() {
      process.exit();
    },
  })
  .command({
    name: "clear",
    description: "clears the console",
    async onExecute() {
      console.clear();
    },
  })
  .command({
    name: "delimiter",
    description: "changes the delimiter",
    async onExecute(a) {
      cli.delimiter = a.parsedArgs.get(0);
    },
    options: [
      {
        name: "delimiter",
        required: true,
      }
    ]
  })
  .command({
    name: "test groups",
    description: "logs command groups",
    async onExecute(a) {
      if (!a.argStr) console.log(cli.commandGroups);
      else console.log(JSON.stringify(cli.commandGroups, null, 2))
    },
    options: [
      {
        name: "stringfy",
        required: false,
      }
    ]
  })

cli.delimiter = "> ";

cli.show();
2.2.9

1 year ago

2.2.8

1 year ago

2.2.7

2 years ago

2.2.6

2 years ago

2.2.4

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.1

2 years ago

2.2.0

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago