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

dsh

v1.0.1

Published

A shell written in JavaScript

Downloads

3

Readme

DSH

NPM Package MIT license

DSH - pronounced dash - is a full featured shell written in JavaScript, which gives you endless possibilities of transforming your app into a shell application. It handles the whole user interaction and you can focus on working with the requested command with your parser.

Usage

The terminal window shown above can be implemented with the following snippet:

var shell = require('dsh');

// Add event listener for an command executed
shell.on('exec', function(cmd) {
   console.log('Command:', cmd);
});

// Say something
shell.on('open', function() {
   this.write("Welcome to DSH\n");
});

shell.on('exit', function() {
    this.write("See you...\n");
});

// Set some options
shell.setOptions({
  ps: '$ ',
  history: '/home/.dsh_history'
});

// Start the shell
shell.open();

Features

  • Configurable History
  • Asynchronous execution
  • No pre-set parser, full control of the input
  • Small codebase, easy extensible

Methods

open()

Function to open the actual shell

exit()

Function to exit the program

setOption(key[, value])

Sets the value of an option listed below. key is either an object of multiple option key-value pairs or one value is presented as a key value parameter.

on(ev, fn)

Sets the callback fn on event ev (see below for a full list of available events)

Attributes

history

An array of commands, that were entered in the past

running

A boolean flag if a long running task is still allowed to run. See gps example in the examples folder.

Events

open

The event is triggered when the shell is opened. This is the right place for your message of the day.

exit

The event is triggered before the program is getting terminated.

exec

The event is triggered for every command submitted. The callback has one parameter, the command itself.

control

The event is triggered when the user hits ctrl+ (key is any a-z without c for the moment). The callback has one parameter, the key.

Options

async

Boolean if the exec event should be asynchronous. If it is, the callback has a second argument, the done() callback. See the MySQL client in the examples folder.

ps

The prompt string, which gets prepended of each line. Default is '>> '

useAlert

Boolean to notify the user of small interaction mistakes by playing the typical beep sound. Default is true.

exitOnCtrlC

Boolean if the shell should exit when ctrl-c is invoked. Default is true. Alternative would be to call exit() on your own.

abortOnCtrlC

If exitOnCtrlC is false, then ctrl-c can be used to abort the actual writing of a command.

historyPath

The file path to the history file. Default is null, which means no history file is written

historyLimit

The maximum number of lines getting written back to the history file. Default is null, which means everything is written

historyIgnoreDuplicate

Boolean to ignore a command of being written to history twice, if the previous command was the same. Default is false, so every command is written to history

Copyright and licensing

Copyright (c) 2016, Robert Eisele ([email protected]) Dual licensed under the MIT or GPL Version 2 licenses.