Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ermalkaleci committed Oct 30, 2024
1 parent d5bf235 commit 2477409
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/chopsticks/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const commands = yargs(hideBin(process.argv))
'Path to config file with default options',
() => ({}), // we load config in middleware
)
.options(getYargsOptions(configSchema.shape)),
.options(getYargsOptions(configSchema.shape))
.deprecateOption('addr', '⚠️ Use --host instead.'),
async (argv) => {
await setupWithServer(configSchema.parse(argv))
},
Expand Down Expand Up @@ -101,6 +102,7 @@ const commands = yargs(hideBin(process.argv))
.alias('wasm-override', 'w')
.usage('Usage: $0 <command> [options]')
.example('$0', '-c acala')
.showHelpOnFail(false)

if (!environment.DISABLE_PLUGINS) {
pluginExtendCli(
Expand Down
6 changes: 1 addition & 5 deletions packages/chopsticks/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ export const zHex = z.custom<HexString>((val: any) => /^0x\w+$/.test(val))
export const zHash = z.string().length(66).and(zHex)

export const configSchema = z.object({
addr: z
.union([z.literal('localhost'), z.string().ip()], {
description: '[DEPRECATED] Use --host instead',
})
.optional(),
addr: z.union([z.literal('localhost'), z.string().ip()]).optional(),
host: z
.union([z.literal('localhost'), z.string().ip()], {
description: 'Server listening interface',
Expand Down
6 changes: 6 additions & 0 deletions packages/chopsticks/src/schema/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { expect, it } from 'vitest'
it('get yargs options from zod schema', () => {
expect(getYargsOptions(configSchema.shape)).toMatchInlineSnapshot(`
{
"addr": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": "string",
},
"allow-unresolved-imports": {
"choices": undefined,
"demandOption": false,
Expand Down

0 comments on commit 2477409

Please sign in to comment.