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

@learnersguild/game-cli

v2.1.4

Published

Option parser for Learners Guild commands.

Downloads

24

Readme

game-cli

Code Climate GPA Code Climate Issue Count Test Coverage

Learners Guild game command-line interface (CLI).

Getting Started

Read the instructions for contributing.

  1. Globally install nvm, avn, and avn-nvm.

    curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
    npm install -g avn avn-nvm
    avn setup
  2. Clone the repository.

  3. Run the setup tasks:

     $ npm install
     $ npm test

How to Define New Commands

All of the existing top-level commands are defined in the config/commands folder, one .yaml file per command. To add a new command, simply create a .yaml file with the name of the command. Each command and subcommand supports the following attributes:

  • name primary name of option
  • abbr one character alias of the option
  • alias other options treated as alias
  • boolean if true, the option is seen as a boolean flag
  • help usage string for the option
  • default default value of the option
  • commands nested subcommands, which also support this same list of attributes
  • _inactive if true, the command or subcommand will be ignored

It's worth noting that the attributes are an extension of cliclopts.

How to Use

  1. Install the module in your project

     $ npm install --save @learnersguild/game-cli
  2. Use whichever command modules you want by importing them

    import {vote} from '@learnersguild/game-cli'
    
    const args = vote.parse(['44', '45'])
    const usageText = vote.usage(args)
    if (usageText) {
      console.info(usageText)
      return 1
    }
    
    // ... do something with args to make voting happen

The Command Runner

There's a built-in command-runner that can be used for development / testing. It is implemented in /src/runner.js, and can be invoked as an npm script:

    $ npm run command -- vote 44 45

The command runner supports different ways to authenticate / impersonate. The easiest way is to find the CLI_COMMAND_TOKEN environment variable, and send it along with the desired handle for the user as whom you'd like to authenticate. For example:

    $ npm run command -- --token=abcd1234zyxw9876 --handle=joeschmoe vote 44 45

If you don't pass the handle option, the command runner will try to deduce it from your ~/.gitconfig by pulling the user attribute from the [github] section.

Alternatively, you can authenticate using a non-expired JWT that you can steal from your browser cookie using the browser developer tools. To do this, you can either pass that JWT along via the lgJWT option. For example:

    $ npm run command -- --lgJWT=<SUPER LONG TOKEN> vote 44 45

If you don't pass the lgJWT option, the command runner will try to deduce it from a ~/.lgrc file that looks something like this:

{
  "lgJWT" : "<LONG SSO JWT TOKEN>",
}

Notes

It may help to look at subcli for more detail on how the argument parsing is handled.

License

See the LICENSE file.