tsdown + cli with commander (#17)
* feat: tsdown * fix: formatting * automate version updates in cli * fix: docs * scenarios * fix: commander deps
This commit is contained in:
parent
18f48e5dea
commit
7f1515c475
1 changed files with 1600 additions and 539 deletions
44
src/schemas.ts
Normal file
44
src/schemas.ts
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import { z } from 'zod';
|
||||
import { getScenario, getClientScenario } from './scenarios';
|
||||
|
||||
// Client command options schema
|
||||
export const ClientOptionsSchema = z.object({
|
||||
command: z.string().min(1, 'Command cannot be empty'),
|
||||
scenario: z
|
||||
.string()
|
||||
.min(1, 'Scenario cannot be empty')
|
||||
.refine(
|
||||
(scenario) => getScenario(scenario) !== undefined,
|
||||
(scenario) => ({
|
||||
message: `Unknown scenario '${scenario}'`
|
||||
})
|
||||
),
|
||||
timeout: z
|
||||
.string()
|
||||
.transform((val) => parseInt(val, 10))
|
||||
.pipe(
|
||||
z
|
||||
.number()
|
||||
.positive('Timeout must be a positive number')
|
||||
.int('Timeout must be an integer')
|
||||
),
|
||||
verbose: z.boolean().optional()
|
||||
});
|
||||
|
||||
export type ClientOptions = z.infer<typeof ClientOptionsSchema>;
|
||||
|
||||
// Server command options schema
|
||||
export const ServerOptionsSchema = z.object({
|
||||
url: z.string().url('Invalid server URL'),
|
||||
scenario: z
|
||||
.string()
|
||||
.refine(
|
||||
(scenario) => getClientScenario(scenario) !== undefined,
|
||||
(scenario) => ({
|
||||
message: `Unknown scenario '${scenario}'`
|
||||
})
|
||||
)
|
||||
.optional()
|
||||
});
|
||||
|
||||
export type ServerOptions = z.infer<typeof ServerOptionsSchema>;
|
||||
Loading…
Reference in a new issue