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

x/cliffy/examples/flags/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 { ITypeInfo, parseFlags } from "../../flags/mod.ts";
const result = parseFlags(Deno.args, { flags: [{ name: "foo", type: "float", }], parse: ({ label, name, value, type }: ITypeInfo) => { switch (type) { case "float": if (isNaN(Number(value))) { throw new Error( `${label} "${name}" must be of type "${type}", but got "${value}".`, ); } return parseFloat(value); default: throw new Error(`Unknown type "${type}".`); } },});
console.log(result);