@types/optimist
- Version 0.0.33
- Published
- 6.35 kB
- No dependencies
- MIT license
Install
npm i @types/optimist
yarn add @types/optimist
pnpm add @types/optimist
Overview
TypeScript definitions for optimist
Index
Variables
variable optimist
var optimist: optimist.Parser;
Interfaces
interface Opt
interface Opt {}
interface Parser
interface Parser {}
property argv
argv: any;
Implicitly use process.argv array to construct the argv object
method alias
alias: { (key: string, alias: string | string[]): Parser; (aliases: { [index: string]: string | string[] }): Parser;};
Set key names as equivalent such that updates to a key will propagate to aliases and vice-versa.
Take an object that maps keys to aliases.
method boolean
boolean: { (key: string): Parser; (key: string[]): Parser };
Interpret key as a boolean. If a non-flag option follows key in process.argv, that string won't get set as the value of key. If key never shows up as a flag in process.arguments, argv[key] will be false.
Interpret all the elements as booleans.
method check
check: (fn: (argv: any) => any) => Parser;
Check that certain conditions are met in the provided arguments. If fn throws or returns false, show the thrown error, usage information, and exit.
method default
default: { (key: string, value: any): Parser; (defaults: { [index: string]: any }): Parser;};
Set argv[key] to value if no option was specified on process.argv
Take an object that maps keys to default values
method demand
demand: { (key: string): Parser; (key: number): Parser; (key: string[]): Parser;};
Show the usage information and exit if key wasn't specified in process.argv
Demand at least as many non-option arguments, which show up in argv._
Demand each element in key
method describe
describe: { (key: string, desc: string): Parser; (descriptions: { [index: string]: string }): Parser;};
Describe a key for the generated usage information
Take an object that maps keys to descriptions
method help
help: () => string;
Return the generated usage string.
method options
options: { (key: string, opt: Opt): Parser; (options: { [index: string]: Opt }): Parser;};
Instead of chaining together, e.g. optimist.alias().demand().default()..., you can specify keys in opt for each of the chainable methods.
Take an object that maps keys to opt parameters
method parse
parse: (args: string[]) => any;
Use .parse() to do the same thing as treating optimist as a function
method showHelp
showHelp: (fn?: (message: string) => void) => void;
Print the usage data using fn for printing (defaults to console.error).
method string
string: { (key: string): Parser; (key: string[]): Parser };
Tell the parser logic not to interpret key as a number or boolean. This can be useful if you need to preserve leading zeros in an input.
Interpret all the elements as strings
method usage
usage: (message: string) => Parser;
Set a usage message to show which commands to use. Inside message, the string $0 will get interpolated to the current script name or node command for the present script similar to how $0 works in bash or perl.
method wrap
wrap: (columns: number) => Parser;
Format usage output to wrap at columns many columns.
call signature
(args: string[]): any;
Pass in the process.argv yourself
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/optimist
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/optimist)
- HTML<a href="https://www.jsdocs.io/package/@types/optimist"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 1264 ms. - Missing or incorrect documentation? Open an issue for this package.