

 

\doxysection*{Yargs }



{\bfseries{Yargs be a node.\+js library fer hearties tryin\textquotesingle{} ter parse optstrings}} 

~\newline


\href{https://travis-ci.org/yargs/yargs}{\texttt{ }} \href{https://coveralls.io/github/yargs/yargs}{\texttt{ }} \href{https://www.npmjs.com/package/yargs}{\texttt{ }} \href{http://standardjs.com/}{\texttt{ }} \href{https://conventionalcommits.org/}{\texttt{ }} \href{http://devtoolscommunity.herokuapp.com}{\texttt{ }}\hypertarget{md_sfcode_node_modules_yargs_README_autotoc_md34650}{}\doxysubsection{Description \+:}\label{md_sfcode_node_modules_yargs_README_autotoc_md34650}
Yargs helps you build interactive command line tools, by parsing arguments and generating an elegant user interface.

It gives you\+:


\begin{DoxyItemize}
\item commands and (grouped) options ({\ttfamily my-\/program.\+js serve -\/-\/port=5000}).
\item a dynamically generated help menu based on your arguments.
\end{DoxyItemize}

\begin{quote}
 \end{quote}

\begin{DoxyItemize}
\item bash-\/completion shortcuts for commands and options.
\item and tons more.
\end{DoxyItemize}\hypertarget{md_sfcode_node_modules_yargs_README_autotoc_md34651}{}\doxysubsection{Installation}\label{md_sfcode_node_modules_yargs_README_autotoc_md34651}
Stable version\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{npm i yargs }

\end{DoxyCode}


Bleeding edge version with the most recent features\+: 
\begin{DoxyCode}{0}
\DoxyCodeLine{npm i yargs@next }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_yargs_README_autotoc_md34652}{}\doxysubsection{Usage \+:}\label{md_sfcode_node_modules_yargs_README_autotoc_md34652}
\hypertarget{md_sfcode_node_modules_yargs_README_autotoc_md34653}{}\doxysubsubsection{Simple Example}\label{md_sfcode_node_modules_yargs_README_autotoc_md34653}

\begin{DoxyCode}{0}
\DoxyCodeLine{\#!/usr/bin/env node}
\DoxyCodeLine{const argv = require('yargs').argv}
\DoxyCodeLine{}
\DoxyCodeLine{if (argv.ships > 3 \&\& argv.distance < 53.5) \{}
\DoxyCodeLine{  console.log('Plunder more riffiwobbles!')}
\DoxyCodeLine{\} else \{}
\DoxyCodeLine{  console.log('Retreat from the xupptumblers!')}
\DoxyCodeLine{\} }

\end{DoxyCode}



\begin{DoxyCode}{0}
\DoxyCodeLine{\$ ./plunder.js -\/-\/ships=4 -\/-\/distance=22}
\DoxyCodeLine{Plunder more riffiwobbles!}
\DoxyCodeLine{}
\DoxyCodeLine{\$ ./plunder.js -\/-\/ships 12 -\/-\/distance 98.7}
\DoxyCodeLine{Retreat from the xupptumblers! }

\end{DoxyCode}
\hypertarget{md_sfcode_node_modules_yargs_README_autotoc_md34654}{}\doxysubsubsection{Complex Example}\label{md_sfcode_node_modules_yargs_README_autotoc_md34654}

\begin{DoxyCode}{0}
\DoxyCodeLine{\#!/usr/bin/env node}
\DoxyCodeLine{require('yargs') // eslint-\/disable-\/line}
\DoxyCodeLine{  .command('serve [port]', 'start the server', (yargs) => \{}
\DoxyCodeLine{    yargs}
\DoxyCodeLine{      .positional('port', \{}
\DoxyCodeLine{        describe: 'port to bind on',}
\DoxyCodeLine{        default: 5000}
\DoxyCodeLine{      \})}
\DoxyCodeLine{  \}, (argv) => \{}
\DoxyCodeLine{    if (argv.verbose) console.info(`start server on :\$\{argv.port\}`)}
\DoxyCodeLine{    serve(argv.port)}
\DoxyCodeLine{  \})}
\DoxyCodeLine{  .option('verbose', \{}
\DoxyCodeLine{    alias: 'v',}
\DoxyCodeLine{    default: false}
\DoxyCodeLine{  \})}
\DoxyCodeLine{  .argv }

\end{DoxyCode}


Run the example above with {\ttfamily -\/-\/help} to see the help for the application.\hypertarget{md_sfcode_node_modules_yargs_README_autotoc_md34655}{}\doxysubsection{Community \+:}\label{md_sfcode_node_modules_yargs_README_autotoc_md34655}
Having problems? want to contribute? join our \href{http://devtoolscommunity.herokuapp.com}{\texttt{ community slack}}.\hypertarget{md_sfcode_node_modules_yargs_README_autotoc_md34656}{}\doxysubsection{Documentation \+:}\label{md_sfcode_node_modules_yargs_README_autotoc_md34656}
\hypertarget{md_sfcode_node_modules_yargs_README_autotoc_md34657}{}\doxysubsubsection{Table of Contents}\label{md_sfcode_node_modules_yargs_README_autotoc_md34657}

\begin{DoxyItemize}
\item Yargs\textquotesingle{} API
\item Examples
\item Parsing Tricks
\begin{DoxyItemize}
\item \href{/docs/tricks.md\#stop}{\texttt{ Stop the Parser}}
\item \href{/docs/tricks.md\#negate}{\texttt{ Negating Boolean Arguments}}
\item \href{/docs/tricks.md\#numbers}{\texttt{ Numbers}}
\item \href{/docs/tricks.md\#arrays}{\texttt{ Arrays}}
\item \href{/docs/tricks.md\#objects}{\texttt{ Objects}}
\end{DoxyItemize}
\item Advanced Topics
\begin{DoxyItemize}
\item \href{/docs/advanced.md\#commands}{\texttt{ Composing Your App Using Commands}}
\item \href{/docs/advanced.md\#configuration}{\texttt{ Building Configurable CLI Apps}}
\item \href{/docs/advanced.md\#customizing}{\texttt{ Customizing Yargs\textquotesingle{} Parser}}
\end{DoxyItemize}
\item Contributing 
\end{DoxyItemize}