Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/cliffy/examples/command/custom_option_processing.ts

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Go to Latest
File
#!/usr/bin/env -S deno run
import { Command } from "../../command/command.ts";
const { options } = await new Command() .option( "-o, --object <item:string>", "map string to object", (value: string): { value: string } => { return { value }; }, ) .option("-C, --color <item:string>", "collect colors", { collect: true, value: (value: string, previous: string[] = []): string[] => { if (["blue", "yellow", "red"].indexOf(value) === -1) { throw new Error( `Option "color" must be one of "blue, yellow or red", but got "${value}".`, ); } previous.push(value); return previous; }, }) .parse(Deno.args);
console.log(options);