From d5abaeda14fce314519d0ef91bce18d71b197df5 Mon Sep 17 00:00:00 2001 From: bn-l Date: Thu, 4 Apr 2024 22:29:01 +1100 Subject: [PATCH] unhandled handling --- coverage/coverage.txt | 6 +- coverage/lcov-report/cli.mts.html | 68 +++++++-- coverage/lcov-report/index.html | 38 ++--- coverage/lcov-report/main.mts.html | 112 ++++++++------- coverage/lcov.info | 213 ++++++++++++++++------------- source/index.mts | 2 + 6 files changed, 259 insertions(+), 180 deletions(-) diff --git a/coverage/coverage.txt b/coverage/coverage.txt index 458280e..daf072e 100644 --- a/coverage/coverage.txt +++ b/coverage/coverage.txt @@ -1,7 +1,7 @@ ----------|---------|----------|---------|---------|------------------- File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s ----------|---------|----------|---------|---------|------------------- -All files | 100 | 94.2 | 100 | 100 | - cli.mts | 100 | 100 | 100 | 100 | - main.mts | 100 | 92.15 | 100 | 100 | 154-155 +All files | 99.04 | 93.24 | 100 | 99.04 | + cli.mts | 97.98 | 95 | 100 | 97.98 | 139-141 + main.mts | 100 | 92.59 | 100 | 100 | 156-157 ----------|---------|----------|---------|---------|------------------- diff --git a/coverage/lcov-report/cli.mts.html b/coverage/lcov-report/cli.mts.html index d3b836c..968fdb8 100644 --- a/coverage/lcov-report/cli.mts.html +++ b/coverage/lcov-report/cli.mts.html @@ -23,16 +23,16 @@

All files cli.mts

- 100% + 97.98% Statements - 133/133 + 146/149
- 100% + 95% Branches - 18/18 + 19/20
@@ -44,9 +44,9 @@

All files cli.mts

- 100% + 97.98% Lines - 133/133 + 146/149
@@ -196,7 +196,23 @@

All files cli.mts

131 132 133 -1341x +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +1501x 1x 1x 1x @@ -272,6 +288,12 @@

All files cli.mts

1x 1x 1x +1x +1x +1x +1x +1x +21x 21x 21x 21x @@ -324,6 +346,16 @@

All files cli.mts

21x 21x 21x +21x +21x +21x +191x +  +  +  +191x +21x +21x 1x 1x 1x @@ -357,11 +389,14 @@

All files cli.mts

export enum Option { dest = "dest", list = "list", + prefix = "prefix", colors = "colors", caseInsensitive = "caseInsensitive", conflictsOnly = "conflictsOnly", keepIf = "keepIf", quiet = "quiet", + help = "help", + version = "version", }   export const helpText = ` @@ -378,6 +413,8 @@

All files cli.mts

-l, --list List files. Useful as a dry run and with fzf. Does not download. Will show show conflicts for the current working directory if -d / --dest is not specified. + -p, --prefix Append the owner/repo prefix to the path in list output + Useful for feeding back into ${ name }. -c, --conflicts-only Only show conflicts when listing. -d, --dest <folder> Destination folder. Defaults to the current directory. -i, --case-insensitive Ignores case when checking for conflicts. Default is @@ -413,6 +450,10 @@

All files cli.mts

type: "boolean", shortFlag: "l", }, + [Option.prefix]: { + type: "boolean", + shortFlag: "p", + }, [Option.colors]: { type: "boolean", default: !noColor(), @@ -434,11 +475,11 @@

All files cli.mts

type: "string", choices: ["newer", "existing"], }, - help: { + [Option.help]: { type: "boolean", shortFlag: "h", }, - version: { + [Option.version]: { type: "boolean", shortFlag: "v", }, @@ -455,6 +496,13 @@

All files cli.mts

// to undefined--which the spread operator ignores. ...(argv && { argv }), }); +  + for (const flag of Object.keys(cli.flags)) { + if (!(flag in Option)) { + console.error(`\nError: Uknown flag "${ flag }". Run ${ name } -h to show help.\n`); + process.exit(1); + } + }   if (cli.input.length === 0) { console.error(`\nError: Need at least one path. Run ${ name } -h to show help.\n`); @@ -469,7 +517,7 @@

All files cli.mts