

 

\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://www.npmjs.com/package/yargs}{\texttt{ }} \href{http://standardjs.com/}{\texttt{ }} \href{https://github.com/yargs/yargs/blob/master/.nycrc}{\texttt{ }} \href{https://conventionalcommits.org/}{\texttt{ }} \href{http://devtoolscommunity.herokuapp.com}{\texttt{ }}\hypertarget{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23315}{}\doxysubsection{Description \+:}\label{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23315}
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_protractor_node_modules_yargs_README_autotoc_md23316}{}\doxysubsection{Installation}\label{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23316}
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_protractor_node_modules_yargs_README_autotoc_md23317}{}\doxysubsection{Usage \+:}\label{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23317}
\hypertarget{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23318}{}\doxysubsubsection{Simple Example}\label{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23318}

\begin{DoxyCode}{0}
\DoxyCodeLine{\#!/usr/bin/env node}
\DoxyCodeLine{const \{argv\} = require('yargs')}
\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_protractor_node_modules_yargs_README_autotoc_md23319}{}\doxysubsubsection{Complex Example}\label{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23319}

\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{    type: 'boolean',}
\DoxyCodeLine{    description: 'Run with verbose logging'}
\DoxyCodeLine{  \})}
\DoxyCodeLine{  .argv }

\end{DoxyCode}


Run the example above with {\ttfamily -\/-\/help} to see the help for the application.\hypertarget{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23320}{}\doxysubsection{Type\+Script}\label{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23320}
yargs has type definitions at \href{https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs}{\texttt{ @types/yargs}}.


\begin{DoxyCode}{0}
\DoxyCodeLine{npm i @types/yargs -\/-\/save-\/dev }

\end{DoxyCode}


See usage examples in docs.\hypertarget{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23321}{}\doxysubsection{Webpack}\label{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23321}
See usage examples of yargs with webpack in docs.\hypertarget{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23322}{}\doxysubsection{Community \+:}\label{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23322}
Having problems? want to contribute? join our \href{http://devtoolscommunity.herokuapp.com}{\texttt{ community slack}}.\hypertarget{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23323}{}\doxysubsection{Documentation \+:}\label{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23323}
\hypertarget{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23324}{}\doxysubsubsection{Table of Contents}\label{md_sfcode_node_modules_protractor_node_modules_yargs_README_autotoc_md23324}

\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}}
\item \href{/docs/tricks.md\#quotes}{\texttt{ Quotes}}
\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}