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

@simple-cli/base

v1.1.2

Published

A simple CLI framework

Downloads

21

Readme

simple-cli

A simple, batteries-included CLI framework for NodeJS and TypeScript.

Tell me more

Disclaimer: Still in development

TLDR

This project is in TypeScript, it provides a simplified way to define custom commands and use some bundled commands, along with the execution logic of the application, including alias expansion, option defaults, and a third-party plugin interface as primary pillars of the design.

The long version

I don't know about you, but when I want to make a CLI, it's to get something done. A quick and dirty script proves useful enough to warrant evolution. A process or resource needs to be codified for structured interactions. Typically, I choose a language I'm proficient in, my company has domain knowledge with, something that requires minimal overhead for consumers to install and run, will work on macOS / Windows / Linux, and finally, a language with a large ecosystem and supporting packages that make writing a program more of stacking up a bunch of blocks.

Luckily, the future is now and a good number of languages meet this criteria. I still find myself reaching for JS/TS when the primary goal is minimal development time.

As for assembling blocks, well, there probably are some options at this level of abstraction. However, in my experience, I'm aware of several popular argument parsing libraries, but not a good, well-known equivalent of create-react-app or nextJS for CLI. Or, maybe just not one that has the features I want. So, this framework is the collection of a few blocks pre-assembled into a foundation that facilitates building robust, and powerful CLI applications on top of.

This framework is all about the common features and extensibility, the simplest way to just say, "yes, I want those features in this CLI", and then start building so you can get that thing done and it will be awesome.

Features

Help

help is the most basic common command. Print out information about all the commands or a specific one, every CLI needs this.

Configuration

config provides 3 functions out-of-the box to provide a user-level persistent storage of convenience optimizations.

  1. Profiles: You might use the same tool in a number of different ways or contexts, so a profile saves and restores a group of configuration under an alias.
  2. Aliases: Take a long string of text or set of options and provide a short alias. Your aliases will be expanded from the original argv before being parsed into commands and options.
  3. Defaults: Are you running a command using the same value for an option? Set it as a default and your option will be populated from this value. Aliases will be expanded, and therefore can act as a semantic-identifier for a more volatile or dynamic parameter.

Plugins

Why stop with what your code does? Provide an API your command can interop with and then let your users load arbitrary modules with the functions they want.

The primary use-case this feature was designed around is time-series analysis. I wanted to run common analysis tasks on time-series data (a list of time, value pairs). Specifying how to source this data and process it has a number of general parameters and then an arbitrary number of source-specific parameters. For instance, I might always want to configure the range of time to look at, and what kind of analysis to run. The input format is always the same, and thus the processing is common. I generalized a tool to do time-series analysis: @tsa-tools/cli. However, it's also reasonable to want to swap out the actual data source and run this code in other contexts. For example, I want to look at performance of some servers using Grafana: tsa-plugin-grafana. If you want to run analysis on... ? Just make a module to source the data given some input parameters and use the existing CLI.