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

mrchimp-cmd

v1.1.1

Published

Command line website

Downloads

4

Readme

cmd

HTML5 Command Line Terminal

Cmd turns a div into a kind of command line. It is designed to take a string input and return a plain text or HTML response by processing the input using Javascript or by using a remote server via a JSON API. It is designed to be extended and as such only provides a few basic commands (see below).

Cmd was built for Chimpcom (Github).

MIT License

Demo

Features

  • Tab completion for command names and parameters
  • JSON API
  • Text-to-speech output (optional, where available)

Bower

You can get Cmd with bower.

bower install cmd

Usage

Make an empty div.

<div id="cmd"></div>

Run some javascript.

var console = new Cmd({
    selector: '#cmd'
});

For more examples see example.html.

Options

selector

Required. (string: '#cmd') Selector for div to use as terminal.

busy_text

(string: 'Communicating...') Text to display when input is disabled during external processor requests.

external_processor

(function: noop)

Parameters:

  • string input The command given by the user.
  • object cmd Reference to the Cmd object.

To add extra commands to Cmd, pass a callback function in the options. This function should either return a response object (see below) or undefined.

If input is undefined, the command line will remain disabled until `handleResponse()`` is called.

The value that external_processor returns defines how Cmd reacts:

  • true - Cmd will remain deactivated until your external script calls handleResponse.
  • false - unknown_cmd will be printed to screen.
  • object - Will be interpreted as a Cmd response object. See below for definition.
  • string - Will be output to screen.
  • Anything else - unknown_cmd will be printed to screen.

filedrop_enabled

(boolean: false) If true, the terminal will allow files to be dropped on it and will post them to file_upload_url.

file_upload_url

(string: 'uploadfile.php') Used when filedrop_enabled is true. A URL to post to when files are dropped on the terminal.

history_id

(string: 'cmd_history') Command history is stored in Local Storage. Use different ids if using multiple terminals on a page. Or don't and they'll share history. It's up to you.

remote_cmd_list_url

(string: '') A URL that provides a JSON representation of available remote commands that is used for command name tabcomplete. This is called once at boot time.

tabcomplete_url

(string: '') A URL that provides parameter tabcompletion result when the input is more than one word.

talk

(boolean: false) Enable talk mode by default.

typewriter_time

(string: 32) Time between typewriter output keypresses.

typewriter_threshold

(string: 200) Output length longer than this will not use the typewriter effect.

unknown_cmd

(string: 'Unrecognised command') String to respond with when unable to process a command.

Response Object

The response object that is passed to handleResponse can have the following parameters.

  • cmd_in - required The input provided by the user.
  • cmd_out - required The response string.
  • redirect - URL to redirect browser to.
  • openWindow - URL to open in a new window.
  • log - String to output with console.log().
  • hide_output - Mask cmd_in as asterisks when outputting.
  • show_pass - Switch to password input.
  • cmd_fill - String to insert into input.

Methods

appendOutput

Params: (string msg) - Append msg to the output.

clearScreen

Same as calling the clear command. Removes all output. Clears the screen. How else can I put it.

handleResponse

Params: (object response) - Called by external_processor to output a response. See above for response specification.

invert

Toggle between light-on-dark and dar-on-light styles.

setPrompt

Params: (string new_prompt) - Change the prompt string.

showInputType

Params: (string input_type) - Changes the type of input used. input_type should be 'password' (masks input as asterisks), 'textarea' (for large format text) or 'normal' (single line input). (If input_type is not set, 'normal' will be used).

Default Commands

clear / cls / clr

Clear the screan. Same as clear on Unix or cls on Windows.

clearhistory

The command history that is accessed with the up arrow is stored in the browser's local storage. clearhistory empties this list.

invert

Toggle between light-on-dark and dark-and-light styles.

talk

Toggle talk mode. When talk mode is enabled, responses will be read aloud.

shh

"Panic button" that silences current speech and empties the talk queue. Talk mode remains enabled.