@helios-lang/cli-utils
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "@helios-lang/cli-utils", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Simplest possible cli library", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -83,7 +83,7 @@ import {} from "@helios-lang/type-utils" | ||
if (i >= this.args.length - 1) { | ||
throw new CliError(`expected argument after ${this.args[i]}`) | ||
} | ||
if (i >= 0) { | ||
if (i >= this.args.length - 1) { | ||
throw new CliError(`expected argument after ${this.args[i]}`) | ||
} | ||
if (i >= 0) { | ||
if (this.used.has(i + 1)) { | ||
@@ -90,0 +90,0 @@ throw new CliError( |
@@ -41,3 +41,3 @@ import { ArgReader } from "../ArgReader.js" | ||
makeHelp() { | ||
return `${this.long}${this.short ? `, ${this.short}` : ""} <${this.variants.join(" | ")}> ${this.description}` | ||
return `${this.long}${this.short ? `, ${this.short}` : ""} <${this.variants.join(" | ")}> ${this.description ?? ""}` | ||
} | ||
@@ -44,0 +44,0 @@ |
@@ -33,3 +33,3 @@ import { ArgReader } from "../ArgReader.js" | ||
makeHelp() { | ||
return `${this.long}${this.short ? `, ${this.short}` : ""}` | ||
return `${this.long}${this.short ? `, ${this.short}` : ""} ${this.description ?? ""}` | ||
} | ||
@@ -45,37 +45,1 @@ | ||
} | ||
/** | ||
* @typedef {OptConfig & { | ||
* default?: string | (() => string) | ||
* }} StringOptConfig | ||
*/ | ||
/** | ||
* @implements {Opt<string>} | ||
*/ | ||
export class StringOpt { | ||
/** | ||
* @param {StringOptConfig} param0 | ||
*/ | ||
constructor({ long, short, description, default: def }) { | ||
this.long = long | ||
this.short = short | ||
this.description = description | ||
this.default = def | ||
} | ||
/** | ||
* @returns {string} | ||
*/ | ||
makeHelp() { | ||
return `${this.long}${this.short ? `, ${this.short}` : ""} <arg> ${this.description}` | ||
} | ||
/** | ||
* | ||
* @param {ArgReader} r | ||
*/ | ||
read(r) { | ||
return r.readOption(this.long, this.short, this.default) | ||
} | ||
} |
@@ -36,3 +36,3 @@ import { ArgReader } from "../ArgReader.js" | ||
makeHelp() { | ||
return `${this.long}${this.short ? `, ${this.short}` : ""} <arg> ${this.description}` | ||
return `${this.long}${this.short ? `, ${this.short}` : ""} <arg> ${this.description ?? ""}` | ||
} | ||
@@ -39,0 +39,0 @@ |
@@ -32,36 +32,6 @@ /** | ||
} | ||
/** | ||
* @typedef {OptConfig & { | ||
* default?: string | (() => string) | ||
* }} StringOptConfig | ||
*/ | ||
/** | ||
* @implements {Opt<string>} | ||
*/ | ||
export class StringOpt implements Opt<string> { | ||
/** | ||
* @param {StringOptConfig} param0 | ||
*/ | ||
constructor({ long, short, description, default: def }: StringOptConfig); | ||
long: string; | ||
short: string | undefined; | ||
description: string | undefined; | ||
default: string | (() => string) | undefined; | ||
/** | ||
* @returns {string} | ||
*/ | ||
makeHelp(): string; | ||
/** | ||
* | ||
* @param {ArgReader} r | ||
*/ | ||
read(r: ArgReader): string; | ||
} | ||
export type OptConfig = import("./Opt.js").OptConfig; | ||
export type Opt<T> = import("./Opt.js").Opt<T>; | ||
export type FlagOptConfig = OptConfig; | ||
export type StringOptConfig = OptConfig & { | ||
default?: string | (() => string); | ||
}; | ||
import { ArgReader } from "../ArgReader.js"; | ||
//# sourceMappingURL=FlagOpt.d.ts.map |
Sorry, the diff of this file is not supported yet
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
29973
878