What it does

Yargs helps you build interactive command line tools by parsing arguments and generating an elegant user interface.

Yargs gives you:

  • commands and (grouped) options (like module run -n --force),
  • a dynamically generated help menu based on your arguments,
  • bash-completion shortcuts for commands and options,
  • and much more.

With these features, and many more, yargs allows you to focus on building your program without worrying about your args.

Yargs is very widely-used. Some products you may have heard of that use Yargs are:

Facebook

https://github.com/facebook/jest

https://github.com/facebook/nuclide

https://github.com/facebook/react-native

GitHub

https://github.com/atom/atom

Google

https://github.com/google/santa-tracker-web https://github.com/google/Chrome.Docs

Heroku

https://github.com/heroku/uku

Release 7.0

At HackIllinois, we moved Yargs towards its next major release, 7.0.

Here is a link to the 7.x branch:

https://github.com/yargs/yargs/tree/7.x

Over the course of the hackathon, we in total:

  • Merged 13 pull requests
    • #806
    • #767
    • #805
    • #804
    • #785
    • #802
    • #799
    • #790
    • #796
    • #797
    • #779
    • #787
    • #786
  • Closed 5 issues
    • #801
    • #795
    • #800
    • #798
    • #791
  • Moved Yargs to the step right before pushing out the 7.0 release.

Below is a detailed changelog:

Bug Fixes

  • address min/max validation message regression (#750) (2e5ce0f)
  • address positional argument strict() bug introduced in #766 (#784) (a8528e6)
  • console.warn() rather than throwing errors when api signatures are incorrect (#804) (a607061)
  • context should override parsed argv (#786) (0997288)
  • context variables are now recognized in strict() mode (#796) (48575cd)
  • errors were not bubbling appropriately from sub-commands to top-level (#802) (8a992f5)
  • positional arguments of sub-commands threw strict() exception (#805) (f3f074b)
  • pull in yargs-parser with modified env precedence (#787) (e0fbbe5)
  • running parse() multiple times on the same yargs instance caused exception if help() enabled (#790) (07e39b7)
  • use path.resolve() to support node 0.10 (#797) (49a93fc)

Features

  • add conflicts and implies shorthands. (#753) (bd1472b)
  • add traditional Chinese translation (#780) (6ab6a95)
  • allow provided config object to extend other configs (#779) (3280dd0)
  • function argument validation (#773) (22ed9bb)
  • if only one column is provided for examples, allow it to take up the entire line (#749) (7931652)
  • introduce custom yargs error object (#765) (8308efa)
  • introduces support for default commands, using the '*' identifier (#785) (d78a0f5)
  • rethink how options are inherited by commands (#766) (ab1fa4b)

BREAKING CHANGES

  • extends key in config file is now used for extending other config files
  • environment variables now take precedence over config files.
  • context now takes precedence over argv and defaults
  • the arguments passed to functions are now validated, there's a good chance this will throw exceptions for a few folks who are using the API in an unexpected way.
  • by default options, and many of yargs' parsing helpers will now default to being applied globally; such that they are no-longer reset before being passed into commands.
  • yargs will no longer aggressively suppress errors, allowing errors that are not generated internally to bubble.

Slack Bot

One of the most interesting features of Yargs is how easy it is to make chat bots with the library. Chat bots are rapidly gaining popularity, being used increasingly by customer support and even at fashion shows to allow attendees to buy the clothing as it is released during the show. We created a HackIllinois Chat Bot. You can find it here:

https://github.com/bcoe/hackillinois-bot

The chat bot is loaded onto the HackIllinois Slack so that you can spam the channels. Here is a brief overview of the core functionality:

/hi ask <message> Ask a JavaScript question! The chat bot will search through Stack Overflow to find an answer to your JavaScript question. We used elastic search and vector space model with term frequency inverse document frequency and document length normalization!

/hi cowsay <message> Display your message in a chat bubble above an ascii cow. Thank you to Geeky Time for submitting this feature!

/hi flip <message> Display your message flipped upside down! Amazing!

/hi asciiface Display a random ascii face! A very useful feature!

/hi issues Displays 3 random issues from Github tagged with HackIllinois!

Thank you to Aashna and Anshil for adding the super cool ask JavaScript question feature to the chat bot! And thank you Ben for all the mentorship and help you provided, you really made this hackathon experience great for us :)

Share this project:
×

Updates