@thi.ng/args
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -6,2 +6,10 @@ # Change Log | ||
## [0.7.2](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@0.7.1...@thi.ng/args@0.7.2) (2021-08-04) | ||
**Note:** Version bump only for package @thi.ng/args | ||
## [0.7.1](https://github.com/thi-ng/umbrella/compare/@thi.ng/args@0.7.0...@thi.ng/args@0.7.1) (2021-07-29) | ||
@@ -8,0 +16,0 @@ |
@@ -93,29 +93,3 @@ 'use strict'; | ||
const indent = strings$1.repeat(" ", opts.paramWidth); | ||
const format = (ids) => ids.map((id) => { | ||
const spec = specs[id]; | ||
const hint = spec.hint ? ansi(" " + spec.hint, theme.hint) : ""; | ||
const name = ansi(`--${strings$1.kebab(id)}`, theme.param); | ||
const alias = spec.alias | ||
? `${ansi("-" + spec.alias, theme.param)}${hint}, ` | ||
: ""; | ||
const params = `${alias}${name}${hint}`; | ||
const isRequired = spec.optional === false && spec.default === undefined; | ||
const prefixes = []; | ||
isRequired && prefixes.push("required"); | ||
spec.multi && prefixes.push("multiple"); | ||
const prefix = prefixes.length | ||
? ansi(`[${prefixes.join(", ")}] `, isRequired ? theme.required : theme.multi) | ||
: ""; | ||
const defaults = opts.showDefaults && | ||
spec.default != null && | ||
spec.default !== false | ||
? ansi(` (default: ${strings$1.stringify(true)(spec.defaultHint != undefined | ||
? spec.defaultHint | ||
: spec.default)})`, theme.default) | ||
: ""; | ||
return (strings$1.padRight(opts.paramWidth)(params, strings$1.lengthAnsi(params)) + | ||
wrap(prefix + (spec.desc || "") + defaults, opts.lineWidth - opts.paramWidth) | ||
.map((l, i) => (i > 0 ? indent + l : l)) | ||
.join("\n")); | ||
}); | ||
const format = (ids) => ids.map((id) => argUsage(id, specs[id], opts, theme, indent)); | ||
const sortedIDs = Object.keys(specs).sort(); | ||
@@ -140,2 +114,29 @@ const groups = opts.groups | ||
}; | ||
const argUsage = (id, spec, opts, theme, indent) => { | ||
const hint = argHint(spec, theme); | ||
const alias = argAlias(spec, theme, hint); | ||
const name = ansi(`--${strings$1.kebab(id)}`, theme.param); | ||
const params = `${alias}${name}${hint}`; | ||
const isRequired = spec.optional === false && spec.default === undefined; | ||
const prefixes = []; | ||
isRequired && prefixes.push("required"); | ||
spec.multi && prefixes.push("multiple"); | ||
const body = argPrefix(prefixes, theme, isRequired) + | ||
(spec.desc || "") + | ||
argDefault(spec, opts, theme); | ||
return (strings$1.padRight(opts.paramWidth)(params, strings$1.lengthAnsi(params)) + | ||
wrap(body, opts.lineWidth - opts.paramWidth) | ||
.map((l, i) => (i > 0 ? indent + l : l)) | ||
.join("\n")); | ||
}; | ||
const argHint = (spec, theme) => spec.hint ? ansi(" " + spec.hint, theme.hint) : ""; | ||
const argAlias = (spec, theme, hint) => spec.alias ? `${ansi("-" + spec.alias, theme.param)}${hint}, ` : ""; | ||
const argPrefix = (prefixes, theme, isRequired) => prefixes.length | ||
? ansi(`[${prefixes.join(", ")}] `, isRequired ? theme.required : theme.multi) | ||
: ""; | ||
const argDefault = (spec, opts, theme) => opts.showDefaults && spec.default != null && spec.default !== false | ||
? ansi(` (default: ${strings$1.stringify(true)(spec.defaultHint != undefined | ||
? spec.defaultHint | ||
: spec.default)})`, theme.default) | ||
: ""; | ||
const ansi = (x, col) => col != null ? `\x1b[${col}m${x}\x1b[0m` : x; | ||
@@ -142,0 +143,0 @@ const wrap = (str, width) => str |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@thi.ng/strings"),require("@thi.ng/checks"),require("@thi.ng/errors")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/strings","@thi.ng/checks","@thi.ng/errors"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.args={}),e.thi.ng.strings,e.thi.ng.checks,e.thi.ng.errors)}(this,(function(e,t,i,s){"use strict";const n={default:95,hint:90,multi:90,param:96,required:33};class r{constructor(e){this.value=e}deref(){return this.value}}const a=e=>i.isNumericFloat(e)?parseFloat(e):s.illegalArgs(`not a numeric value: ${e}`),l=e=>e.map(a),o=e=>i.isHex(e)?parseInt(e,16):s.illegalArgs(`not a hex value: ${e}`),c=e=>e.map(o),u=e=>i.isNumericInt(e)?parseInt(e):s.illegalArgs(`not an integer: ${e}`),g=e=>e.map(u),p=e=>JSON.parse(e),h=e=>t=>e.includes(t)?t:s.illegalArgs(`invalid option: ${t}`);function f(e="=",t=!1,i=!1){return n=>n.reduce(((n,r)=>{const a=r.indexOf(e);if(t&&a<1&&s.illegalArgs(`got '${r}', but expected a 'key${e}value' pair`),a>0){const e=r.substr(0,a),t=r.substr(a+1);i?n[e]?n[e].push(t):n[e]=[t]:n[e]=t}else n[r]=i?["true"]:"true";return n}),{})}const d=(e,t,i=",")=>n=>{const a=n.split(i);return a.length!==t&&s.illegalArgs(`got '${n}', but expected a tuple of ${t} values`),new r(a.map(e))},m=(e,t)=>i=>Object.assign({coerce:e,hint:t,group:"main"},i),b=(e,t)=>i=>Object.assign({hint:$(t,i.delim),multi:!0,coerce:e,group:"main"},i),$=(e,t)=>e+(t?`[${t}..]`:""),O=m((e=>e),"STR"),j=b((e=>e),"STR"),v=m(a,"NUM"),x=m(o,"HEX"),A=m(u,"INT"),k=b(l,"NUM"),y=b(c,"HEX"),I=b(g,"INT"),w=(e,t)=>`${t?t+": ":""}${e.map((e=>`"${e}"`)).join(", ")}`,N=(e,i,s,n=",")=>Object.assign({coerce:d(e,i,n),hint:[...t.repeat("N",i)].join(n),group:"main"},s),T=(e,i={})=>{const s=!1!==(i=Object.assign({lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"]},i)).color?Object.assign(Object.assign({},n),i.color):{},r=t.repeat(" ",i.paramWidth),a=n=>n.map((n=>{const a=e[n],l=a.hint?W(" "+a.hint,s.hint):"",o=W(`--${t.kebab(n)}`,s.param),c=`${a.alias?`${W("-"+a.alias,s.param)}${l}, `:""}${o}${l}`,u=!1===a.optional&&void 0===a.default,g=[];u&&g.push("required"),a.multi&&g.push("multiple");const p=g.length?W(`[${g.join(", ")}] `,u?s.required:s.multi):"",h=i.showDefaults&&null!=a.default&&!1!==a.default?W(` (default: ${t.stringify(!0)(null!=a.defaultHint?a.defaultHint:a.default)})`,s.default):"";return t.padRight(i.paramWidth)(c,t.lengthAnsi(c))+H(p+(a.desc||"")+h,i.lineWidth-i.paramWidth).map(((e,t)=>t>0?r+e:e)).join("\n")})),l=Object.keys(e).sort(),o=i.groups?i.groups.map((t=>[t,l.filter((i=>e[i].group===t))])).filter((e=>!!e[1].length)):[["options",l]];return[...H(i.prefix,i.lineWidth),...o.map((([e,t])=>[...i.showGroupNames?[`${e}:\n`]:[],...a(t),""].join("\n"))),...H(i.suffix,i.lineWidth)].join("\n")},W=(e,t)=>null!=t?`[${t}m${e}[0m`:e,H=(e,i)=>e?t.wordWrapLines(e,{width:i,splitter:t.SPLIT_ANSI,hard:!0}):[],S=(e,t,i)=>{const n=q(e),r={};let a,l,o=i.start;for(;o<t.length;){const s=t[o];if(a){if(M(l,r,a,s))break;a=null,o++}else{if(i.help.includes(s))return void console.log(T(e,i.usageOpts));const t=E(e,n,r,s);if(a=t.id,l=t.spec,o+=~~(t.state<2),t.state)break}}return a&&s.illegalArgs(`missing value for: --${a}`),{result:D(e,r),index:o,rest:t.slice(o),done:o>=t.length}},q=e=>Object.entries(e).reduce(((e,[t,i])=>i.alias?(e[i.alias]=t,e):e),{}),E=(e,i,n,r)=>{if("-"===r[0]){let a;if("-"===r[1]){if("--"===r)return{state:1};a=t.camel(r.substr(2))}else a=i[r.substr(1)],!a&&s.illegalArgs(`unknown option: ${r}`);const l=e[a];return!l&&s.illegalArgs(a),l.flag&&(n[a]=!0,a=void 0,l.fn&&!l.fn("true"))?{state:1,spec:l}:{state:0,id:a,spec:l}}return{state:2}},M=(e,t,n,r)=>(/^-[a-z]/i.test(r)&&s.illegalArgs(`missing value for: --${n}`),e.multi?i.isArray(t[n])?t[n].push(r):t[n]=[r]:t[n]=r,e.fn&&!e.fn(r)),D=(e,t)=>{let i;for(let n in e)i=e[n],void 0===t[n]?void 0!==i.default?t[n]=i.default:!1===i.optional&&s.illegalArgs(`missing arg: --${n}`):i.coerce&&F(i,t,n);return t},F=(e,t,i)=>{try{e.multi&&e.delim&&(t[i]=t[i].reduce(((t,i)=>(t.push(...i.split(e.delim)),t)),[])),t[i]=e.coerce(t[i])}catch(e){throw new Error(`arg --${i}: ${e.message}`)}};e.DEFAULT_THEME=n,e.Tuple=r,e.coerceFloat=a,e.coerceFloats=l,e.coerceHexInt=o,e.coerceHexInts=c,e.coerceInt=u,e.coerceInts=g,e.coerceJson=p,e.coerceKV=f,e.coerceOneOf=h,e.coerceString=e=>e,e.coerceTuple=d,e.flag=e=>Object.assign({flag:!0,default:!1,group:"flags"},e),e.float=v,e.floats=k,e.hex=x,e.hexes=y,e.int=A,e.ints=I,e.json=e=>Object.assign({coerce:p,hint:"JSON",group:"main"},e),e.kvPairs=(e,t="=",i)=>Object.assign({coerce:f(t,i),hint:`key${t}val`,multi:!0,group:"main"},e),e.kvPairsMulti=(e,t="=",i)=>Object.assign({coerce:f(t,i,!0),hint:`key${t}val(s)`,multi:!0,group:"main"},e),e.oneOf=(e,t)=>Object.assign(Object.assign({coerce:h(e),hint:"ID",group:"main"},t),{desc:w(e,t.desc)}),e.oneOfMulti=(e,t)=>Object.assign(Object.assign({coerce:t=>t.map(h(e)),hint:$("ID",t.delim),multi:!0,group:"main"},t),{desc:w(e,t.desc)}),e.parse=(e,t,i)=>{i=Object.assign({start:2,showUsage:!0,help:["--help","-h"]},i);try{return S(e,t,i)}catch(t){throw i.showUsage&&console.log(t.message+"\n\n"+T(e,i.usageOpts)),t}},e.size=(e,t,i="x")=>N(u,e,t,i),e.string=O,e.strings=j,e.tuple=N,e.usage=T,e.vec=(e,t,i=",")=>N(a,e,t,i),Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@thi.ng/strings"),require("@thi.ng/checks"),require("@thi.ng/errors")):"function"==typeof define&&define.amd?define(["exports","@thi.ng/strings","@thi.ng/checks","@thi.ng/errors"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).thi=e.thi||{},e.thi.ng=e.thi.ng||{},e.thi.ng.args={}),e.thi.ng.strings,e.thi.ng.checks,e.thi.ng.errors)}(this,(function(e,t,i,s){"use strict";const n={default:95,hint:90,multi:90,param:96,required:33};class r{constructor(e){this.value=e}deref(){return this.value}}const a=e=>i.isNumericFloat(e)?parseFloat(e):s.illegalArgs(`not a numeric value: ${e}`),l=e=>e.map(a),o=e=>i.isHex(e)?parseInt(e,16):s.illegalArgs(`not a hex value: ${e}`),c=e=>e.map(o),u=e=>i.isNumericInt(e)?parseInt(e):s.illegalArgs(`not an integer: ${e}`),g=e=>e.map(u),p=e=>JSON.parse(e),h=e=>t=>e.includes(t)?t:s.illegalArgs(`invalid option: ${t}`);function f(e="=",t=!1,i=!1){return n=>n.reduce(((n,r)=>{const a=r.indexOf(e);if(t&&a<1&&s.illegalArgs(`got '${r}', but expected a 'key${e}value' pair`),a>0){const e=r.substr(0,a),t=r.substr(a+1);i?n[e]?n[e].push(t):n[e]=[t]:n[e]=t}else n[r]=i?["true"]:"true";return n}),{})}const d=(e,t,i=",")=>n=>{const a=n.split(i);return a.length!==t&&s.illegalArgs(`got '${n}', but expected a tuple of ${t} values`),new r(a.map(e))},m=(e,t)=>i=>Object.assign({coerce:e,hint:t,group:"main"},i),b=(e,t)=>i=>Object.assign({hint:$(t,i.delim),multi:!0,coerce:e,group:"main"},i),$=(e,t)=>e+(t?`[${t}..]`:""),O=m((e=>e),"STR"),j=b((e=>e),"STR"),v=m(a,"NUM"),x=m(o,"HEX"),A=m(u,"INT"),k=b(l,"NUM"),y=b(c,"HEX"),I=b(g,"INT"),w=(e,t)=>`${t?t+": ":""}${e.map((e=>`"${e}"`)).join(", ")}`,N=(e,i,s,n=",")=>Object.assign({coerce:d(e,i,n),hint:[...t.repeat("N",i)].join(n),group:"main"},s),T=(e,i={})=>{const s=!1!==(i=Object.assign({lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"]},i)).color?Object.assign(Object.assign({},n),i.color):{},r=t.repeat(" ",i.paramWidth),a=t=>t.map((t=>W(t,e[t],i,s,r))),l=Object.keys(e).sort(),o=i.groups?i.groups.map((t=>[t,l.filter((i=>e[i].group===t))])).filter((e=>!!e[1].length)):[["options",l]];return[...D(i.prefix,i.lineWidth),...o.map((([e,t])=>[...i.showGroupNames?[`${e}:\n`]:[],...a(t),""].join("\n"))),...D(i.suffix,i.lineWidth)].join("\n")},W=(e,i,s,n,r)=>{const a=H(i,n),l=`${S(i,n,a)}${M(`--${t.kebab(e)}`,n.param)}${a}`,o=!1===i.optional&&void 0===i.default,c=[];o&&c.push("required"),i.multi&&c.push("multiple");const u=q(c,n,o)+(i.desc||"")+E(i,s,n);return t.padRight(s.paramWidth)(l,t.lengthAnsi(l))+D(u,s.lineWidth-s.paramWidth).map(((e,t)=>t>0?r+e:e)).join("\n")},H=(e,t)=>e.hint?M(" "+e.hint,t.hint):"",S=(e,t,i)=>e.alias?`${M("-"+e.alias,t.param)}${i}, `:"",q=(e,t,i)=>e.length?M(`[${e.join(", ")}] `,i?t.required:t.multi):"",E=(e,i,s)=>i.showDefaults&&null!=e.default&&!1!==e.default?M(` (default: ${t.stringify(!0)(null!=e.defaultHint?e.defaultHint:e.default)})`,s.default):"",M=(e,t)=>null!=t?`[${t}m${e}[0m`:e,D=(e,i)=>e?t.wordWrapLines(e,{width:i,splitter:t.SPLIT_ANSI,hard:!0}):[],F=(e,t,i)=>{const n=U(e),r={};let a,l,o=i.start;for(;o<t.length;){const s=t[o];if(a){if(_(l,r,a,s))break;a=null,o++}else{if(i.help.includes(s))return void console.log(T(e,i.usageOpts));const t=P(e,n,r,s);if(a=t.id,l=t.spec,o+=~~(t.state<2),t.state)break}}return a&&s.illegalArgs(`missing value for: --${a}`),{result:J(e,r),index:o,rest:t.slice(o),done:o>=t.length}},U=e=>Object.entries(e).reduce(((e,[t,i])=>i.alias?(e[i.alias]=t,e):e),{}),P=(e,i,n,r)=>{if("-"===r[0]){let a;if("-"===r[1]){if("--"===r)return{state:1};a=t.camel(r.substr(2))}else a=i[r.substr(1)],!a&&s.illegalArgs(`unknown option: ${r}`);const l=e[a];return!l&&s.illegalArgs(a),l.flag&&(n[a]=!0,a=void 0,l.fn&&!l.fn("true"))?{state:1,spec:l}:{state:0,id:a,spec:l}}return{state:2}},_=(e,t,n,r)=>(/^-[a-z]/i.test(r)&&s.illegalArgs(`missing value for: --${n}`),e.multi?i.isArray(t[n])?t[n].push(r):t[n]=[r]:t[n]=r,e.fn&&!e.fn(r)),J=(e,t)=>{let i;for(let n in e)i=e[n],void 0===t[n]?void 0!==i.default?t[n]=i.default:!1===i.optional&&s.illegalArgs(`missing arg: --${n}`):i.coerce&&L(i,t,n);return t},L=(e,t,i)=>{try{e.multi&&e.delim&&(t[i]=t[i].reduce(((t,i)=>(t.push(...i.split(e.delim)),t)),[])),t[i]=e.coerce(t[i])}catch(e){throw new Error(`arg --${i}: ${e.message}`)}};e.DEFAULT_THEME=n,e.Tuple=r,e.coerceFloat=a,e.coerceFloats=l,e.coerceHexInt=o,e.coerceHexInts=c,e.coerceInt=u,e.coerceInts=g,e.coerceJson=p,e.coerceKV=f,e.coerceOneOf=h,e.coerceString=e=>e,e.coerceTuple=d,e.flag=e=>Object.assign({flag:!0,default:!1,group:"flags"},e),e.float=v,e.floats=k,e.hex=x,e.hexes=y,e.int=A,e.ints=I,e.json=e=>Object.assign({coerce:p,hint:"JSON",group:"main"},e),e.kvPairs=(e,t="=",i)=>Object.assign({coerce:f(t,i),hint:`key${t}val`,multi:!0,group:"main"},e),e.kvPairsMulti=(e,t="=",i)=>Object.assign({coerce:f(t,i,!0),hint:`key${t}val(s)`,multi:!0,group:"main"},e),e.oneOf=(e,t)=>Object.assign(Object.assign({coerce:h(e),hint:"ID",group:"main"},t),{desc:w(e,t.desc)}),e.oneOfMulti=(e,t)=>Object.assign(Object.assign({coerce:t=>t.map(h(e)),hint:$("ID",t.delim),multi:!0,group:"main"},t),{desc:w(e,t.desc)}),e.parse=(e,t,i)=>{i=Object.assign({start:2,showUsage:!0,help:["--help","-h"]},i);try{return F(e,t,i)}catch(t){throw i.showUsage&&console.log(t.message+"\n\n"+T(e,i.usageOpts)),t}},e.size=(e,t,i="x")=>N(u,e,t,i),e.string=O,e.strings=j,e.tuple=N,e.usage=T,e.vec=(e,t,i=",")=>N(a,e,t,i),Object.defineProperty(e,"__esModule",{value:!0})})); |
{ | ||
"name": "@thi.ng/args", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "Declarative, functional & typechecked CLI argument/options parser, value coercions etc.", | ||
@@ -41,6 +41,6 @@ "module": "./index.js", | ||
"dependencies": { | ||
"@thi.ng/api": "^7.1.6", | ||
"@thi.ng/api": "^7.1.7", | ||
"@thi.ng/checks": "^2.9.8", | ||
"@thi.ng/errors": "^1.3.2", | ||
"@thi.ng/strings": "^2.1.2" | ||
"@thi.ng/strings": "^2.1.3" | ||
}, | ||
@@ -76,3 +76,3 @@ "files": [ | ||
}, | ||
"gitHead": "2c0a80e5c455fe9f302548e16b4eedbc62cacc73" | ||
"gitHead": "a85a4dd69e086a18d97d22204667c6b5334b01e0" | ||
} |
@@ -65,3 +65,3 @@ <!-- This file is generated - DO NOT EDIT! --> | ||
Package sizes (gzipped, pre-treeshake): ESM: 2.32 KB / CJS: 2.45 KB / UMD: 2.38 KB | ||
Package sizes (gzipped, pre-treeshake): ESM: 2.38 KB / CJS: 2.52 KB / UMD: 2.43 KB | ||
@@ -68,0 +68,0 @@ ## Dependencies |
55
usage.js
@@ -8,29 +8,3 @@ import { kebab, lengthAnsi, padRight, repeat, SPLIT_ANSI, stringify, wordWrapLines, } from "@thi.ng/strings"; | ||
const indent = repeat(" ", opts.paramWidth); | ||
const format = (ids) => ids.map((id) => { | ||
const spec = specs[id]; | ||
const hint = spec.hint ? ansi(" " + spec.hint, theme.hint) : ""; | ||
const name = ansi(`--${kebab(id)}`, theme.param); | ||
const alias = spec.alias | ||
? `${ansi("-" + spec.alias, theme.param)}${hint}, ` | ||
: ""; | ||
const params = `${alias}${name}${hint}`; | ||
const isRequired = spec.optional === false && spec.default === undefined; | ||
const prefixes = []; | ||
isRequired && prefixes.push("required"); | ||
spec.multi && prefixes.push("multiple"); | ||
const prefix = prefixes.length | ||
? ansi(`[${prefixes.join(", ")}] `, isRequired ? theme.required : theme.multi) | ||
: ""; | ||
const defaults = opts.showDefaults && | ||
spec.default != null && | ||
spec.default !== false | ||
? ansi(` (default: ${stringify(true)(spec.defaultHint != undefined | ||
? spec.defaultHint | ||
: spec.default)})`, theme.default) | ||
: ""; | ||
return (padRight(opts.paramWidth)(params, lengthAnsi(params)) + | ||
wrap(prefix + (spec.desc || "") + defaults, opts.lineWidth - opts.paramWidth) | ||
.map((l, i) => (i > 0 ? indent + l : l)) | ||
.join("\n")); | ||
}); | ||
const format = (ids) => ids.map((id) => argUsage(id, specs[id], opts, theme, indent)); | ||
const sortedIDs = Object.keys(specs).sort(); | ||
@@ -55,2 +29,29 @@ const groups = opts.groups | ||
}; | ||
const argUsage = (id, spec, opts, theme, indent) => { | ||
const hint = argHint(spec, theme); | ||
const alias = argAlias(spec, theme, hint); | ||
const name = ansi(`--${kebab(id)}`, theme.param); | ||
const params = `${alias}${name}${hint}`; | ||
const isRequired = spec.optional === false && spec.default === undefined; | ||
const prefixes = []; | ||
isRequired && prefixes.push("required"); | ||
spec.multi && prefixes.push("multiple"); | ||
const body = argPrefix(prefixes, theme, isRequired) + | ||
(spec.desc || "") + | ||
argDefault(spec, opts, theme); | ||
return (padRight(opts.paramWidth)(params, lengthAnsi(params)) + | ||
wrap(body, opts.lineWidth - opts.paramWidth) | ||
.map((l, i) => (i > 0 ? indent + l : l)) | ||
.join("\n")); | ||
}; | ||
const argHint = (spec, theme) => spec.hint ? ansi(" " + spec.hint, theme.hint) : ""; | ||
const argAlias = (spec, theme, hint) => spec.alias ? `${ansi("-" + spec.alias, theme.param)}${hint}, ` : ""; | ||
const argPrefix = (prefixes, theme, isRequired) => prefixes.length | ||
? ansi(`[${prefixes.join(", ")}] `, isRequired ? theme.required : theme.multi) | ||
: ""; | ||
const argDefault = (spec, opts, theme) => opts.showDefaults && spec.default != null && spec.default !== false | ||
? ansi(` (default: ${stringify(true)(spec.defaultHint != undefined | ||
? spec.defaultHint | ||
: spec.default)})`, theme.default) | ||
: ""; | ||
const ansi = (x, col) => col != null ? `\x1b[${col}m${x}\x1b[0m` : x; | ||
@@ -57,0 +58,0 @@ const wrap = (str, width) => str |
Sorry, the diff of this file is not supported yet
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
99001
1138
Updated@thi.ng/api@^7.1.7
Updated@thi.ng/strings@^2.1.3