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

xwcmd

v0.1.2

Published

Opinionated, Simple and Efficient CLI Builder, happy to Use

Downloads

13

Readme

xwcmd

Opinionated, Simple and Efficient CLI Builder. But more flexible style, happy to Use.

  • Customize some style styles and outputs
  • Just a few simple character definitions
  • Support multi-level subcommands, theoretically can be unlimited subcommand nesting

Usage

Install:

npm install --save xwcmd

usage see test/cli.js

API

define(options)

Create the main Command. the options is a object, reference above example.

setConfig(options)

Set the global configuration of all commands.

options.args

Let me explain, for examples:

import { colors } from 'xwcmd'
...
 [`f,${colors.blue('...files')} <value_hint>`, 'This is a description for files flag' , []]

The first parameter is a flag and it's aliases (this example is -f,---files), the second is this flag's description, and the third is the default value (this example is []).

colors.blue() function from alexeyraspopov/picocolors, so you can use multicolor in your cli. Like highlighting some hints, or arg

<value_hint> is a hint for the value, define by <> parentheses. like description for the value.

The ... is a separator for the data type, ... means the value is an array. The type of arg is defined by prefacing it with a specific character,such as -,'!','...', default: string. - means number type. ! means boolean type. ... means array type.

The type is automatically converted for you, you can also specify the default value.

options.action

The action function is called when the command is executed.

options.name

The name of the command.

options.version

The version of the command.

Command's Method

sub(subCommandMeta, args, action)

Add a sub-command.

cmd.sub(
  ['i,in, install [pkg] <lodash, axios, react>'],
  [
    [`${colors.bgYellow('in')} | number`, `in's description`, 19],
    ['in2', `in2's description`, `in2's defaultValue`]
  ],
  (args, { pkg }) => {
    console.log(`install+++`, args, pkg);
  }
);

The first parameter subCommandMeta is an array of strings that describe the sub-command. like a item defined in args

The second parameter args is an array of flags and their options. it's the same as the args parameter in the define method.

The third parameter action is a function that is called when the sub-command is executed.

subCommandMeta

set(options: Settings)

Set this command configuration options.

default(args: DefaultArgs)

Default command parameters.

cmd.default(['...pkg!']);

call(name:string, argv: any[])

Invoke any registered subcommand.

 cmd.call('any_subcommand', ['default_arg_value', '--flag', 'flag_value'])

examples()

Display examples information

getMeta()

get command's meta information

help()

Display help information

run()

Finally we need to call it

TODO

  • [x] more test
  • [x] value hint.
  • [x] globalSet?
  • [ ] env?
  • [ ] choices.
  • [ ] remove row layout?.

any problem?

Issue or PR is welcome. ❤️

Acknowledgements

mrozio13pl/ofi

alexeyraspopov/picocolors