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

gulp-showhelp

v1.2.0

Published

Gulp plugin to show a help message for your gulpfile.js.

Downloads

29

Readme

gulp-showhelp NPM version MIT License Build Status Build Status Coverage Status

Gulp plugin to show a help message for your gulpfile.js.

Install

Install gulp-showhelp with npm:

$ npm install --save-dev gulp-showhelp

Usage

First, load gulp-showhelp module and add a task to show a help message in your gulpfile.js like following:

var gulp = require('gulp');
var ghelp = require('gulp-showhelp');

gulp.task('help', function() {
  ghelp.show();
}).help = 'shows this help message.'; 

Then, you can show a help message about help task via gulp help.

$ gulp help
[gulp] Starting 'help'...

Usage
  gulp task

Tasks
  help : shows this help message.

[gulp] Finished 'help' after 557 μs

Next, add a description to each tasks. There are three types to add.

Add a task description

1. Task only

If you want to show a description about a task with no option, add help property as a string to a task object, e.g.:

gulp.task('lint', function() {
  ...
}).help = 'lints all js files.';

The result is:

$ gulp help
[gulp] Starting 'help'...

Usage
  gulp task

Tasks
  help : shows this help message.
  lint : lints all js files. 

[gulp] Finished 'help' after 660 μs

2. Task with options

If you want to show a description about a task with some options, add help property as an object to a task object. A value of a propery of which a key is an empty string is treated as a task description.

gulp.task('compile', function() {
  ...
}).help = {
  '': 'compiles source files.',
  '--srcs=pattern': 'specifys a path pattern of source files.',
  '--dest=path': 'specifys a file path.'
};

The result is:

$ gulp help
[gulp] Starting 'help'...

Usage
  gulp task [ option ... ]

Tasks
  help    : shows this help message.
  lint    : lints all js files. 
  compile : compiles source files.
    --srcs=pattern : specifys a path pattern of source files.
    --dest=path : specifys a file path.

[gulp] Finished 'help' after 753 μs

3. Free description using a function

If you want to show a free format description about a task, add help property as a function to a task object. You can use showTask function to show a task description and showOption function to show a option description.

gulp.task('test', function(){
  ...
}).help = function() {
  ghelp.showTask('test', 'tests modules.');
  ghelp.showOption('--case=id', 'specifys a test case ID.');
  var text = '\n' +
    '    Test case IDs:\n' +
    '        ID  :        description\n' +
    '      ------:-------------------------------------\n' +
    '      case1 : .... \n' +
    '      case2 : .... \n' +
    '      case3 : .... \n' +
    '';
  console.log(text);
};

The result is:

$ gulp help
[gulp] Starting 'help'...

Usage
  gulp task [ option ... ]

Tasks
  help    : shows this help message.
  lint    : lints all js files. 
  compile : compiles source files.
    --srcs=pattern : specifys a path pattern of source files.
    --dest=path : specifys a file path.
  test    : tests modules.
    --case=id : specifys a test case ID.

    Test case IDs:
        ID  :        description
      ------:-------------------------------------
      case1 : .... 
      case2 : .... 
      case3 : .... 


[gulp] Finished 'help' after 934 μs

Select and order tasks

You can select and order tasks of which you want to show a description by specifying task names in order.

gulp.task('help', function() {
  ghelp.show('lint', 'help', '', 'compile');
}).help = 'shows this help message.'; 

If a null or an empty string is specified as a task name, an empty line is displayed.

Select a task via a command-line argument.

If you want to be able to select a task via a command-line argument, getArgv function is useful. Write as follows:

gulp.task('help', function() {
  var task = ghelp.getArgv('task', 't');
  if (task != null) {
    ghelp.show(task);
  } else {
    ghelp.show();
  }
}).help = {
  '': 'shows this help message.',
  '[ --task=t ]': 'specifys a task shown. Alias: -t.' 
};

APIs

API names are changed to camel case according to JavaScript coding conventions. So the functions show_task, show_option, get_argv are deprecated, but they are left for compatibility.

gulp-showhelp provides the following functions:

.show([ ...taskname ]) : Void

Shows a help message about all tasks or specified tasks in gulpfile.js.

Parameters:

| Parameter | Type | Description | |:------------|:------:|:--------------------------------------------------------| | taskname | string | A task name. If null or empty, displays an empty line. |

.show(tasknames) : Void

Shows a help message about tasks specified by an array in gulpfile.js.

Parameters:

| Parameter | Type | Description | |:------------|:--------:|:------------------------------------------------------| | tasknames | Array | An array which contains task names. |

.showTask(taskname, taskdesc) : Void

Shows a task description using a help message.

| Parameter | Type | Description | |:------------|:------:|:--------------------------------------------------------| | taskname | string | A task name. | | taskdesc | string | A task explanation. |

.showOption(optionname, optiondesc) : Void

Shows a option description using a help message.

| Parameter | Type | Description | |:-------------|:------:|:-------------------------------------------------------| | optionname | string | An option name. | | optiondesc | string | An option explanation. |

.getArgv(optionname [, optionalias, ...]) : Void

Gets a option value corresponding to the specified option name or alias.

| Parameter | Type | Description | |:--------------|:------:|:------------------------------------------------------| | optionname | string | An option name. | | optionalias | string | An option alias. |

.taskNames() : Array

Gets an array which contains all task names.

Returns:

An array of task names.

Type: Array

License

Copyright (C) 2014-2017 Takayuki Sato.

This program is free software under MIT License. See the file LICENSE in this distribution for more details.