Comparing version 0.0.1 to 0.0.2
@@ -101,4 +101,8 @@ // src/cli.ts | ||
// src/tree.ts | ||
var REQUIRED = `required`; | ||
var OPTIONAL = `optional`; | ||
function required(arg) { | ||
return [`required`, arg]; | ||
} | ||
function optional(arg) { | ||
return [`optional`, arg]; | ||
} | ||
@@ -145,3 +149,3 @@ // src/cli.ts | ||
const [key, config] = entry; | ||
const { flag: flag2, required, description, example } = config; | ||
const { flag: flag2, required: required2, description, example } = config; | ||
const parse = `parse` in config ? config.parse : parseStringOption; | ||
@@ -151,3 +155,3 @@ const argumentInstances = passed.filter((arg) => arg.startsWith(`--${key}`) || arg.startsWith(`-`) && !arg.startsWith(`--`) && flag2 && arg.split(`=`)[0].includes(flag2)); | ||
case 0: | ||
if (required && !optionsFromConfig) { | ||
if (required2 && !optionsFromConfig) { | ||
logger.error(`parsing`, key, `\n\t[Required]: ${description}\n\tExample usage: ${example}`); | ||
@@ -184,8 +188,8 @@ failedValidation = true; | ||
export { | ||
required, | ||
parseStringOption, | ||
parseNumberOption, | ||
parseBooleanOption, | ||
cli, | ||
REQUIRED, | ||
OPTIONAL | ||
optional, | ||
cli | ||
}; |
{ | ||
"name": "comline", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -89,26 +89,15 @@ # comline | ||
```typescript | ||
import { Tree, TreePath, OPTIONAL, REQUIRED } from "comline" | ||
import type { Tree, TreePath } from "comline" | ||
import { optional, required } from "comline" | ||
const myTree = [ | ||
REQUIRED, | ||
{ | ||
hello: [ | ||
OPTIONAL, | ||
{ | ||
world: null, | ||
$name: [ | ||
OPTIONAL, | ||
{ | ||
good: [ | ||
REQUIRED, | ||
{ | ||
morning: null | ||
} | ||
], | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
] satisfies Tree | ||
const myTree = required({ | ||
hello: optional({ | ||
world: null, | ||
$name: optional({ | ||
good: required({ | ||
morning: null, | ||
}), | ||
}), | ||
}), | ||
}) satisfies Tree | ||
@@ -115,0 +104,0 @@ const validPaths: TreePath<typeof myTree>[] = [ |
@@ -1,3 +0,7 @@ | ||
export const REQUIRED = `required` as const | ||
export const OPTIONAL = `optional` as const | ||
export function required<T>(arg: T): [`required`, T] { | ||
return [`required`, arg] | ||
} | ||
export function optional<T>(arg: T): [`optional`, T] { | ||
return [`optional`, arg] | ||
} | ||
@@ -4,0 +8,0 @@ export type TreeContents = Readonly<{ [key: string]: Tree | null }> |
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
520
19776
117