Détail du package

parsemate

pSkywalker225MIT0.0.13

A tool for building easy argv parsing in app, coupled with a "--help" me generator

argv, argparser, cli, command-line

readme

<!DOCTYPE html>

<html lang="en"> <head> <meta charset="UTF-8"> </head> <body>

🧩 ParseMate

A flexible, zero-dependency TypeScript class for parsing command-line arguments with support for multi-value flags, default values, required arguments, and rich help output.


🚀 Features

  • Define your own argument structure using ArgSpec
  • Support for required flags and multiple values
  • Auto-generated terminal help with examples
  • Simple access to argument values

📦 Installation

This is a self-contained utility. Just include ArgvParser.ts and ArgSpec.ts in your project.

Or install from npm:

npm install parsemate

📄 Usage

import { ArgvParser } from "parsemate";
( () => {
  const appName = "test.js";
const parser = new ArgvParser( appName , { folder: { flags: ['-f', '--folder'], description: 'Folder to scan', required: true, multiple: true, }, tech: { flags: ['-t', '--tech'], description: 'Technologies to process', multiple: true, default: ['html', 'css'], }, output: { flags: ['-o', '--output'], description: 'Output folder', default: 'dist', }, }); for (const [key, value] of parser.entries) { console.log(${key}:, value); } })();

🔧 ArgSpec Type

export type ArgSpec = {
  flags: string[];          // e.g., ['-f', '--folder']
  description: string;
  required?: boolean;
  multiple?: boolean;
  default?: any;
};

🔍 Example Help Output


🧪 API Reference

  • constructor(appName: String, defs: ArgDefinition) – Initialize with a map of argument specs.
  • getArg(name: string) – Get the parsed value for a specific argument.
  • getAll() – Get all parsed arguments as an object.
  • keys – Array of all argument names.
  • values – Array of all parsed values.
  • entries – Array of [key, value] pairs.
  • definitionList – Array of defined arguments and specs.
  • generateHelp(appName?: string) – Returns CLI help string.

📃 License

MIT – Use freely in personal or commercial projects.

</body> </html>