npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@marcuth/argus

v0.1.0

Published

**@marcuth/argus** is a simple and strongly typed command parser built with [Zod](https://zod.dev) for argument validation. It allows you to easily define command prefixes, extract arguments, and validate them against strict schemas.

Readme

@marcuth/argus

@marcuth/argus is a simple and strongly typed command parser built with Zod for argument validation. It allows you to easily define command prefixes, extract arguments, and validate them against strict schemas.

📦 Installation

Installation is straightforward; simply use your preferred package manager. You also need to install zod as a peer dependency. Here is an example using NPM:

npm i @marcuth/argus zod

🚀 Usage

Initialization

To start, create an instance of the Argus class and define the prefix for your commands.

import { Argus, ArgusError } from "@marcuth/argus"
import { z } from "zod"

const argus = new Argus({
    prefix: "!",
    // argumentSeparator: " " // Optional, defaults to space
})

Handling Commands

You can verify if a string is a command, extract its raw arguments, and then validate them using a Zod schema. Arguments are positional and map directly to the keys in your schema.

const text = "!hello world 25"

if (argus.isCommand(text)) {
    try {
        // 1. Extract command name and raw arguments
        const props = argus.extractCommandProps(text)
        
        console.log(`Command: ${props.name}`) // "hello"

        // 2. Define the validation schema
        // Arguments are mapped positionally to these keys
        const optionsSchema = z.object({
            name: z.string(),
            age: z.coerce.number(), // Coerce string to number
            email: z.string().email().optional() // Optional argument
        })

        // 3. Validate and parse the arguments
        const validated = argus.validateCommandWithArguments({
            name: props.name,
            arguments: props.arguments,
            schema: optionsSchema
        })

        console.log("Validated Options:", validated.options)
        // Output: { name: "world", age: 25 }

    } catch (error) {
        if (error instanceof ArgusError) {
            console.error("Command Error:", error.message)
        } else if (error instanceof z.ZodError) {
            console.error("Validation Error:", error.errors)
        }
    }
}

⚙️ Features

  • Custom Prefix: Define any character or string as your command prefix.
  • Zod Powered: Leverage the full power of Zod for validation and transformation (e.g., z.coerce.number()).
  • Positional Mapping: Arguments from the input string are mapped sequentially to your Zod schema keys.
  • Optional Arguments: Support for optional fields at the end of your argument list.

⚠️ Error Handling

Argus throws specific errors that you can catch:

  • ArgusError: Thrown when there's an issue with the arguments count (too many or too few).
  • ZodError: Thrown when argument validation fails against the provided schema (e.g., passing text where a number is expected).

🧪 Testing

Automated tests are located in the __tests__ directory. To run them:

npm run test

🤝 Contributing

Want to contribute? Follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-new).
  3. Commit your changes (git commit -m 'Add new feature').
  4. Push to the branch (git push origin feature-new).
  5. Open a Pull Request.

📝 License

This project is licensed under the MIT License.