@oclif/core
Advanced tools
Comparing version 0.5.17 to 0.5.18
@@ -5,2 +5,9 @@ # Changelog | ||
### [0.5.18](https://github.com/oclif/core/compare/v0.5.17...v0.5.18) (2021-06-28) | ||
### Features | ||
* add docopts ([#188](https://github.com/oclif/core/issues/188)) ([4f38877](https://github.com/oclif/core/commit/4f38877b1e9abb1a19a3bcecde17945f80b2d52d)) | ||
### [0.5.17](https://github.com/oclif/core/compare/v0.5.16...v0.5.17) (2021-06-28) | ||
@@ -7,0 +14,0 @@ |
@@ -408,2 +408,4 @@ "use strict"; | ||
allowNo: flag.allowNo, | ||
dependsOn: flag.dependsOn, | ||
exclusive: flag.exclusive, | ||
}; | ||
@@ -425,2 +427,4 @@ } | ||
options: flag.options, | ||
dependsOn: flag.dependsOn, | ||
exclusive: flag.exclusive, | ||
// eslint-disable-next-line no-await-in-loop | ||
@@ -427,0 +431,0 @@ default: typeof flag.default === 'function' ? await flag.default({ options: {}, flags: {} }) : flag.default, |
@@ -29,4 +29,4 @@ import * as Interfaces from '../interfaces'; | ||
}>; | ||
protected usage(flags: Interfaces.Command.Flag[]): string; | ||
protected defaultUsage(_: Interfaces.Command.Flag[]): string; | ||
protected usage(): string; | ||
protected defaultUsage(): string; | ||
protected description(): string | undefined; | ||
@@ -33,0 +33,0 @@ protected aliases(aliases: string[] | undefined): string | undefined; |
@@ -7,2 +7,3 @@ "use strict"; | ||
const formatter_1 = require("./formatter"); | ||
const docopts_1 = require("./docopts"); | ||
// Don't use os.EOL because we need to ensure that a string | ||
@@ -63,3 +64,3 @@ // written on any platform, that may use \r\n or \n, will be | ||
header: this.opts.usageHeader || 'USAGE', | ||
generate: ({ flags }) => this.usage(flags), | ||
generate: () => this.usage(), | ||
}, | ||
@@ -107,10 +108,23 @@ { | ||
} | ||
usage(flags) { | ||
usage() { | ||
const usage = this.command.usage; | ||
const body = (usage ? util_1.castArray(usage) : [this.defaultUsage(flags)]) | ||
.map(u => `$ ${this.config.bin} ${u}`.trim()) | ||
const body = (usage ? util_1.castArray(usage) : [this.defaultUsage()]) | ||
.map(u => { | ||
const allowedSpacing = this.opts.maxWidth - this.indentSpacing; | ||
const line = `$ ${this.config.bin} ${u}`.trim(); | ||
if (line.length > allowedSpacing) { | ||
const splitIndex = line.substring(0, allowedSpacing).lastIndexOf(' '); | ||
return line.substring(0, splitIndex) + '\n' + | ||
this.indent(this.wrap(line.substring(splitIndex), this.indentSpacing * 2)); | ||
} | ||
return this.wrap(line); | ||
}) | ||
.join('\n'); | ||
return this.wrap(body); | ||
return body; | ||
} | ||
defaultUsage(_) { | ||
defaultUsage() { | ||
// Docopts by default | ||
if (this.opts.docopts === undefined || this.opts.docopts) { | ||
return docopts_1.DocOpts.generate(this.command); | ||
} | ||
return util_1.compact([ | ||
@@ -117,0 +131,0 @@ this.command.id, |
@@ -31,2 +31,6 @@ export interface HelpOptions { | ||
usageHeader?: string; | ||
/** | ||
* Use docopts as the usage. Defaults to true. | ||
*/ | ||
docopts?: boolean; | ||
} |
@@ -113,2 +113,4 @@ import { AlphabetLowercase, AlphabetUppercase } from './alphabet'; | ||
required?: boolean; | ||
dependsOn?: string[]; | ||
exclusive?: string[]; | ||
}; | ||
@@ -126,4 +128,2 @@ export declare type BooleanFlagProps = FlagProps & { | ||
export declare type FlagBase<T, I> = FlagProps & { | ||
dependsOn?: string[]; | ||
exclusive?: string[]; | ||
exactlyOne?: string[]; | ||
@@ -130,0 +130,0 @@ /** |
{ | ||
"name": "@oclif/core", | ||
"description": "base library for oclif CLIs", | ||
"version": "0.5.17", | ||
"version": "0.5.18", | ||
"author": "Jeff Dickey @jdxcode", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/oclif/core/issues", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192968
111
5002