@salesforce/command
Version:
Salesforce CLI base command class
102 lines (101 loc) • 3.03 kB
TypeScript
import { SfdxCommand } from './sfdxCommand';
/**
* DocOpts generator for SfdxCommands. See http://docopt.org/.
*
* flag.exclusive: groups elements when one of the mutually exclusive cases is a required flag: (--apple | --orange)
* flag.exclusive: groups elements when none of the mutually exclusive cases is required (optional flags): [--apple | --orange]
* flag.dependsOn: specifies that if one element is present, then another one is required: (--apple --orange)
* cmd.variableArgs: produces 'name=value'
*
* @example
* {
* name: 'classnames',
* required: true,
* exclusive: ['suitenames']
* ...
* },{
* name: 'suitenames',
* type: 'array'
* required: true
* ...
* }
*
* Results in:
* Usage: <%= command.id %> (-n <string> | -s <array>)
*
* @example
* {
* name: 'classnames',
* ...
* excludes: ['suitenames']
* },{
* name: 'suitenames',
* ...
* }
*
* Results in:
* Usage: <%= command.id %> [-n <string> | -s <string>]
*
* @example
* {
* name: 'classnames',
* ...
* dependsOn: ['suitenames']
* },{
* name: 'suitenames',
* type: 'flag'
* ...
* }
*
* Results in:
* Usage: <%= command.id %> (-n <string> -s)
*
* TODO:
* - Support nesting, eg:
* Usage: my_program (--either-this <and-that> | <or-this>)
* Usage: my_program [(<one-argument> <another-argument>)]
*
* @param cmdDef
*/
export declare class DocOpts<T extends typeof SfdxCommand> {
private cmd;
private flags;
private flagList;
constructor(cmd: T);
static generate<T extends typeof SfdxCommand>(cmdDef: T): string;
toString(): string;
/**
* Group flags that dependOn (and) and are exclusive (or).
*/
private groupFlagElements;
/**
* Combine doc opt elements to another flag's doc opt element. This is for supporting
* things like "and" (dependsOn) and "or" (exclusive).
*
* This will probably break down on complex dependsOn / exclusive flag structures.
* For example, a flag that depends on a flag that depends on another flag.
*
* See tests to see what is supported.
*
* @param elementMap All doc opt elements.
* @param flagName The name of the flag to combine to.
* @param flagNames The other flag names to combine to flagName.
* @param unionString How to combine the doc opt elements.
*/
private combineElementsToFlag;
/**
* Categorize flags into required, optional, builtin opt-in, and mandatory builtin
* flags. This is the order they should appear in the doc opts.
*
* For example, flags defined on the actual command should some before standard
* fields like --json.
*/
private categorizeFlags;
/**
* Generate doc opt elements for all flags.
*
* @param elementMap The map to add the elements to.
* @param flagGroups The flags to generate elements for.
*/
private generateElements;
}