Skip to content

Commit 0d2420a

Browse files
committed
chore: move to arg-parser
1 parent 589f446 commit 0d2420a

File tree

7 files changed

+23
-20
lines changed

7 files changed

+23
-20
lines changed

package-lock.json

Lines changed: 13 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/arg-parser/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"depcheck": "^1.4.7",
4848
"eslint": "^7.25.0",
4949
"mongodb": "^6.19.0",
50-
"prettier": "^2.8.8"
50+
"prettier": "^2.8.8",
51+
"zod": "^3.25.76 || ^4.1.8"
5152
}
5253
}

packages/cli-repl/src/arg-parser.ts renamed to packages/arg-parser/src/arg-parser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { CommonErrors, MongoshUnimplementedError } from '@mongosh/errors';
22
import i18n from '@mongosh/i18n';
33
import type { CliOptions } from '@mongosh/arg-parser';
44
import parser from 'yargs-parser';
5-
import { colorizeForStderr as clr } from './clr';
6-
import { USAGE } from './constants';
5+
import { colorizeForStderr as clr } from '../../cli-repl/src/clr';
6+
import { USAGE } from '../../cli-repl/src/constants';
77
import { z } from 'zod/v4';
88
import type { Options as YargsOptions } from 'yargs-parser';
99

@@ -39,7 +39,6 @@ const OPTIONS_SCHEMA = z
3939
awsIamSessionToken: z.string().optional(),
4040
awsSecretAccessKey: z.string().optional(),
4141
awsSessionToken: z.string().optional(),
42-
browser: z.union([z.boolean(), z.string()]).optional(),
4342
csfleLibraryPath: z.string().optional(),
4443
cryptSharedLibPath: z.string().optional(),
4544
db: z.string().optional(),
@@ -165,11 +164,12 @@ const OPTIONS_SCHEMA = z
165164
.optional()
166165
.register(optionsRegistry, { alias: ['f'] }),
167166

168-
// Special options that can be boolean or string
167+
// Options that can be boolean or string
169168
json: z.union([z.boolean(), z.enum(['relaxed', 'canonical'])]).optional(),
170169
oidcDumpTokens: z
171170
.union([z.boolean(), z.enum(['redacted', 'include-secrets'])])
172171
.optional(),
172+
browser: z.union([z.boolean(), z.string()]).optional(),
173173
})
174174
.loose();
175175

packages/arg-parser/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ export function generateConnectionInfoFromCliArgs(
1919
const connectionString = generateUri(options);
2020
return mapCliToDriver(options, { connectionString, driverOptions: {} });
2121
}
22+
23+
export { parseCliArgs } from './arg-parser';

packages/cli-repl/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@
9393
"semver": "^7.5.4",
9494
"strip-ansi": "^6.0.0",
9595
"text-table": "^0.2.0",
96-
"yargs-parser": "^20.2.4",
97-
"zod": "^3.25.76 || ^4.1.8"
96+
"yargs-parser": "^20.2.4"
9897
},
9998
"devDependencies": {
10099
"@mongodb-js/eslint-config-mongosh": "^1.0.0",

packages/cli-repl/src/run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ enableFipsIfRequested();
1515

1616
import { markTime } from './startup-timing';
1717
import { CliRepl } from './cli-repl';
18-
import { parseCliArgs } from './arg-parser';
18+
import { parseCliArgs } from '@mongosh/arg-parser';
1919
import { runSmokeTests } from './smoke-tests';
2020
import { USAGE } from './constants';
2121
import { baseBuildInfo, buildInfo } from './build-info';

0 commit comments

Comments
 (0)