Bare Minimum Command-Line (CLI) Application Skeleton
import { Denotrodon, Command } from "https://deno.land/x/denotrodon/mod.ts";
import { Denotrodon, Command } from "../mod.ts";
const app: Denotrodon = new Denotrodon();
/**
* Stack Parameters
*
* @run
* deno run .\example\app.ts test -q --name=John -n Aldrich -m "Hello Deno!"
*
* @output
* { name: [ "John", "Aldrich" ], quiet: true }
*/
const commandTest = new Command(function (this: Denotrodon) {
console.log(this.options);
})
.describe("Test command")
.expects({ name: "msg", flag: "m", desc: "Message" })
.expects({ name: "name", flag: "n", desc: "User name", type: "array" })
.optional(
{
name: "quiet",
flag: "q",
type: "boolean",
desc: "Be quiet",
default: false,
},
);
app.command("test", commandTest);
await app.run();
$ deno run ./example/app.ts help
Denotrodon Application 0.1
by Unknown
default Home screen
test Test command
async Async test
help
$ deno run --allow-net ./example/app.ts help test
Test command
--msg -m Message (Required)
--name -n User name (Required)
--quiet -q Be quiet
We have few examples provided, that could be found here.
- Default command
- Extra arguments check
- Help generator for specific command
app help command
- Clean-up
- Example for command
- Test files
- Command completion on Bash
To contribute to Denotrodon! Make sure to give a star and forked this repository.
Alternatively see the GitHub documentation on creating a pull request.
The Denotrodon
is open-sourced software licensed under the MIT license.