๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
Sign inDemoInstall
Socket

parsemate

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parsemate

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

0.0.5
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
ย 
Created
Source

๐Ÿงฉ 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
npm install 

๐Ÿ“„ Usage

import { ArgvParser } from './ArgvParser';
  ( () => {
  const parser = new ArgvParser({
    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(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.

Keywords

argv

FAQs

Package last updated on 01 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts