1.0.0 • Published 4 years ago

@author.io/shell-middleware v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

shell-middleware

Common middleware for @author.io/shell CLI applications (Browser & Node.js runtimes).

To Use:

RuntimeExample
Node.jsInstall: npm install @author.io/shell-middleware -SUsage: import { ValidInput } from '@author.io/shell-middleware'
Browserimport { ValidInput } from 'https://cdn.pika.dev/@author.io/shell-middleware@latest'

Capabilities

This library contains a collection of commonly used middleware methods for use with a shell app.

import { Shell } from 'https://cdn.pika.dev/@author.io/shell@latest'

// Import this library...
import { MiddlewareA, MiddlewareB } from 'https://cdn.pika.dev/@author.io/shell-middleware@latest'

// Simple shell
const shell = new Shell({
  name: 'my-cli'
})

shell.use(<middleware>) // <----- Apply middleware.

...

ValidInput

This method enforces flag processing rules (see @author.io/arg for options). For example, this method will recognize failure to specify a required flag by displaying a violation notice. All further processing is aborted.

import { ValidInput } from '...@author.io/shell-middleware@latest'

shell.use(ValidInput)

ValidInputWithHelp

This is nearly identical to ValidInput, except it will also display the default help message.

import { ValidInputWithHelp } from '...@author.io/shell-middleware@latest'

shell.use(ValidInputWithHelp)

Log

Log the original command. This is a pass-thru method, so processing will continue.

import { Log } from '...@author.io/shell-middleware@latest'

shell.use(Log)