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 🙏

© 2024 – Pkg Stats / Ryan Hefner

shumai

v0.1.2

Published

A delicious new outlook on command line argument handling.

Downloads

20

Readme

Shumai

A delicious new outlook on command line argument handling.


License NPM Version Open Issues Github Stars

A note from the developer: Shumai is an early access package, if you have features you would like to see, please open an issue, I will work to implement all of the features within the scope of this project, and fix issues with current features as I go.

This project is only tested and developed for Bun, any support for NodeJS, or Deno is coincidental and not intentional, please do not submit bug reports for those runtimes (at this time). Support for these runtimes is planned, but not in progress at this time.

Getting Started

To install, firstly ensure you have the Bun runtime installed on your system. Then, you can use the following command to add to your project.

bun add shumai

Using WSL?

One known issue with Bun on WSL is that it fails to install packages due to a "NotSameFilesystem" error, this can be fixed by appending the add command with --backend=copyfile`

Basic application

Importing

To import Shumai into your project, simply include the following line to your project.

import shumai from "shumai";

Shumai currently provides two argument types, Flag, which returns a boolean value, and String, which returns a string value, or null if not present.

All of our argument types use "builder patterns" to provide a consistent API across all types.


Example Flag Argument:

// Generate a new Flag argument.
let help = new shumai.Flag()
                .withName("help")          // Call it "help"
                .withIdentifier("help")    // make it capture "--help"
                .withShortIdentifier("h"); // make it caputre "-h"

This results in a Flag argument, which can be passed to the Shumai Client, or you can use it completely independant of this library, on your own data inputs.


Example String Argument:

// Generate a new String argument.
let file = new shumai.String()
                .withName("file")          // Call it "file"
                .withIdentifier("file")    // make it capture "--file <text>"
                .withShortIdentifier("f"); // make it caputre "-f <text>"

This results in a String argument


In order to process your arguments into something you can use, we can take our example arguments from before, and carry them into the following code.

// Create our client.
let client = new shumai.Shumai([help, file]);

// Run our arguments through the processor.
client.parse();

It is as simple as that, now you can access your command flags using client.values, an example of this field can be seen below:

bun src/app.ts -- --file "/path/to/file.png" -h

would result in

{
    help: true,
    file: "/path/to/file.png"
}

Roadmap

Here is a list of things that are either unfinished, or desireable. Got a feature you fancy? [Create an issue] to possibly see it added to this list:

| Status | Name | Description | |:------:|:----:|:-----------:| |Complete|required arguments|Adds the ability to mark an argument as required, causing Shumai to log the issue to the console and pre-emptively exit the application.| |Complete|onMissing event|A method which is called on required arguments, if no argument is present, but exiting is undesireable| | Pending|multi-value argument|An argument kind which takes a command-seperated list of values, and returns them as an array| | Pending|per-argument event hooks|Adds the ability to implement custom processing logic for just one argument at a time|