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 🙏

© 2025 – Pkg Stats / Ryan Hefner

grunt-generate-cli-markdown

v1.0.3

Published

Generates Markdown documentation for a CLI

Readme

Status GitHub Issues GitHub Pull Requests License Node.js CI


📝 Table of Contents

🏁 Getting Started

This plugin requires Grunt ^1.6.1

  1. Install the plugin:
npm install grunt-generate-cli-markdown --save-dev
  1. Load the plugin: Add this line to your Gruntfile.js file:
grunt.loadNpmTasks('grunt-generate-cli-markdown');
  1. Configure the plugin: Add the following configuration to your Gruntfile.js file:
  generate-cli-markdown: {
    your_target: { // Arbitrary target name
      options: {
        // Add plugin-specific options here. Examples:
        cliPath: 'path/to/your/cli', // Path to your CLI executable
        // other options as needed.
      },
      files: {
        'DESTINATION_README.md': 'SOURCE.md'  // Specify source and destination files
      }
    },
  },

🎈 Usage

generate-cli-markdown: {
  myTarget: { 
   options: {
     cliPath: './bin/mycli',
       // ... other options
   },
   files: {
     'docs/README.md': 'templates/README.md'
   }
 }
}

:gear: Options

  • cliPath (required): The path to the executable file of your CLI tool. (Type: String)

:exclamation: Example

This example demonstrates how to use grunt-generate-cli-markdown with a simple CLI that has two commands (check and build) and a global verbose option. It also showcases the use of command aliases and customizing the help output.

1. Create the CLI:

Create a file named src/index.js (or any name you like, making sure to update the paths in the configuration accordingly) with the following content:

#!/usr/bin/env node
const { program } = require('commander');

program
  .version('1.0.0')
  .option('-v, --verbose', 'Enable verbose output')
  .configureHelp({
    sortCommands: true,
    sortOptions: true,
    showGlobalOptions: true
  });


program
  .command('check', { hidden: false })
  .alias('c')
  .description('Check the project')
  .action(() => {
    console.log('Checking the project...');
  });

program
  .command('build', { hidden: false })
  .alias('b')
  .description('Build the project')
  .action(() => {
    console.log('Building the project...');
  });

program.parse();

2. Create a Gruntfile.js:

Create a file named Gruntfile.js with the following content:

module.exports = function(grunt) {
  grunt.initConfig({
    generate-cli-markdown: {
      myTarget: {
        options: {
          cliPath: './src/index.js', // Path to your CLI
        },
        files: {
          'docs/README.md': 'templates/README.md' // Source and destination for the markdown
        }
      }
    }
  })

  grunt.loadNpmTasks('grunt-generate-cli-markdown');
 
}

3. Install dependencies:

  • Install the commander package:
npm install commander
  • Install the grunt-generate-cli-markdown and grunt packages:
npm install grunt-generate-cli-markdown --save-dev

4. Install the Grunt-CLI package:

npm install -g grunt-cli

5. Run the Grunt task:

grunt generate-cli-markdown

This will generate a markdown file (docs/README.md in this example) containing the documentation for your CLI, including the commands, their descriptions, aliases, and the global verbose option. The generated markdown will also reflect the custom help configuration using sortCommands, sortOptions, and showGlobalOptions.

By modifying the src/index.js file (adding, removing, or changing commands, options, descriptions, etc.), and re-running the grunt generate-cli-markdown task, the generated markdown documentation will automatically update to reflect the changes in your CLI's source code. For instance, adding a new command with its description and options in src/index.js will result in this new command's documentation appearing in the generated markdown after running the Grunt task.

6. Exammine the generated markdown:

# My CLI Tool

7. Change CLI source file:

Update the CLI source file to include more commands, options, and aliases. Rerun the Grunt task to generate the updated markdown.

program
  .command('check', { hidden: false })
  .alias('c')
  .description('Check the project')
  .action(() => {
    console.log('Checking the project...');
  });

program
  .command('build', { hidden: false })
  .alias('b')
  .description('Build the project')
  .action(() => {
    console.log('Building the project...');
  });

program
  .command('deploy', { hidden: false })
  .alias('d')
  .description('Deploy the project')
  .action(() => {
    console.log('Deploying the project...');
  });

program.parse();
grunt generate-cli-markdown

⛏️ Built Using

  • Node.js
  • Grunt

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

💖 Show your support

Give a ⭐️ if this project helped you!

✍️ Authors

📝 License

Copyright © 2024 Ion Gireada. This project is MIT licensed.