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

hubot-detailed-help

v0.0.3

Published

Hubot scripts to display advanced help

Downloads

2

Readme

hubot-detailed-help

A Hubot library to show more detailed help when user asks for the list of commands.

The main purpose of this library to make the help much easier for user to find interesting commands. Each Hubot script should have the Commands section fulfilled - the more scripts you will add, the bigger the help will become. After some time you will find the it to be so overgrown, you would much rather find the Commands section for the script by your own, to remove noise from other libraries.

There are some already existing libraries with similiar functionality - I will try to explain, why this one was created.

Other libraries

hubot-help

The most common one is simple hubot-help. While this library is very good on it's own, it has disadvantages described above - it is too simple and allows to only display all help commands or search one using simple filtering. You can not add your tags, describing the parameters and adding information about aliases will only make the help more complicated.

hubot-advanced-help

The hubot-advanced-help library is much more powerful than the default one. You can add tags to commands and choose between AND/OR filtering. The biggest problem with the library is that you have to manually include script paths for each script - it modified the design of the Commands section, what caused it to be not compatible with existing mechanism.

Functionality

The hubot-detailed-help library allows you to:

  1. Group the commands by the tags
  2. Add the description for the parameters used in the command
  3. Add aliases for the command (when there two or more commands that are doing the same thing)

The flow of using the help

Help is divided into three possible scenarios:

  1. Summary of the help - displays all the commands or tags defined in scripts
  2. Searching for the query and there are multiple matching commands - displays the command - description summary for each command matching the query.
  3. Searching for the query and there is only one matching command - displays the command and description summary, but will also show list of all parameters (with description) and aliases (if there is any).

Collapsing the help using the tag groups

By default, when the user types hubot help, the bot will show all commands with only their descriptions. If there are many commands, the help will become unreadable. To avoid the problem, there is "collapsing mechanism" implemented in the library.

If the HUBOT_COLLAPSE_HELP environment variable will be set to true, the mechanism will collapse all the commands into the groups displaying only the tags (and untagged commands).

Lets use an example. When the variable will not be set, the help will show something like:

 Below you can find all of the commands that I know about. You can also narrow your search by adding some keywords - I will show you only those which you want to find. If only one command matches your query, I will display also more details about it :)
_hubot help_ - Displays help
_hubot help `QUERY`_ - Searches help to find a command matching `QUERY`.
_hubot some command `QUERY`_ - More complicated command
_hubot some untagged command_  - This command remains untagged because of some reason

If we will change the variable to true, the bot will show instead:

Below you can find all of the commands that I know about. You can also narrow your search by adding some keywords - I will show you only those which you want to find. If only one command matches your query, I will display also more details about it :)
I've **grouped the similiar commands by their tags** to make the help easier to read. If you want to show commands from the group, just use help TAG_NAME.
The list of all possible tags:
_HELP_ (2) - Commands used to display help
_EXTERNAL-SCRIPT_ (1) - Commands from the external script
The list of commands that have no tag:
_hubot some untagged command_ - This command remains untagged because of some reason

If the user wants to show the commands from the tag, he should type:

hubot help EXTERNAL-SCRIPT

Displaying the command details

This is the most important functionality of the library - after all, it is named hubot-detailed-help. The details provided in the help will not be shown until the user will want to show information about the specific command (in other words, only one command will match the query). This will prevent the help from being too chaotic to find anything useful.

The details, apart from the command and description, will also display the parameters and aliases list, for example:

_hubot find `ENGINE` `QUERY`_ - Searches the search engine to find any URLs matching query.
Parameters list:
_ENGINE_ - The name of the search engine that will be used to find URLs. Optional, defaults to Google.
_QUERY_ - The string that will be searched
You can also use this command with:
hubot search `ENGINE` `QUERY`
hubot search `QUERY`
hubot find `QUERY`

If there are no parameters or aliases defined, the sections will be simply skipped.

Creating the help entries with the hubot-detailed-help library

This library does not modify the main design of the Commands section. Each entry should still contain command - description pattern - you can add more details by simply extending the description part. This way if somebody will still use simple hubot-help, your scripts will work without any problems (just displaying much more information, which you would add this or another way).

Each extension can be added in any place of the description. Just remember that each command should take exactly one line - there is no possibility to split the commands in separate lines.

Parameters

Parameters can be defined using the {PARAM - DESCRIPTION} syntax, for example: {QUERY - The key to be found}.

Aliases

Aliases can be defined using the <Alias: ALIAS> or simply <ALIAS> syntax, for example: <hubot find> <Alias: hubot search>.

Tags

Tags can be defined by using the [], for example: [TAG-NAME] [ANOTHER-TAG]. Tags can not be described in command line - this is to avoid too many copy-paste of the same description everywhere. Instead, you have to add special entry for each tag as it would be separated command, using the pattern:

TAG [HELP] - Commands used to display help

This way you only have to define the description once and then just use your tag name inside command definitions. Tags without the entry will just have empty description (we recommend adding it for every tag).

User can search by the tag even if it will not be displayed.

Changing the entries format

You can change the way the parameters, tags and commands are displayed by changing the environment variables. The bot will replace the parameters defined as ${parameter} with it's proper value.

| Variable | Default value | Description | | ---------------------- | ------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | | HELP_COMMAND_FORMAT | ${command} - ${description} | The format for displaying the command entry. | | HELP_PARAMETER_FORMAT | ${parameter} - ${description} | The format for displaying the parameter entry | | HELP_TAG_FORMAT | ${tag} (${commands}) - ${description} | The format for displaying the tag entry. commands variable contains the amount of commands stored inside the group. |

Changing the bot responses

If you want to change the language of the help or just simply do not like bot's default responses, you can change them by modifying proper environment variables.

| Variable | Description | | -------------------------- | ------------------------------------------------------------------------------------------------------------------------- | | HUBOT_HELP_HEADER | The main help header, used to inform user about the library's functionality. Displayed only when user types hubot help. | | HUBOT_HELP_COLLAPSED_INFO | Information shown to user when the HUBOT_COLLAPSE_HELP is set to true. Displayed only when user types hubot help. | | HUBOT_HELP_TAGS_INFO | The header for the tags list. Displayed only when the help is opened in collapse mode. | | HUBOT_HELP_UNTAGGED_INFO | The header for the untagged commands list. Displayed only when the help is opened in collapse mode. | | HUBOT_HELP_NOT_FOUND | Information displayed when the bot did not found any command matching user's query. | | HELP_ALIASES_HEADER | The header of the aliases list summary. Displayed only in command's details mode. | | HELP_PARAMETERS_HEADER | The header of the parameters list summary. Displayed only in command's details mode. |

Examples

Best example would be the hubot-detailed-help Hubot script. If you want to see more examples, please use the tests as extended documentation.

Contribution

If you want to contribute, just fork the project and add some changes!

Errors and ideas to improve

If you will find any errors with this library or have great idea how to improve it (and don't want to do it on your own), please feel free to open a new ticket.