|
2 | 2 | import { generate } from "./generate"; |
3 | 3 | import { Command } from "commander"; |
4 | 4 | import packageJson from "../package.json"; |
| 5 | +import { Options } from "openapi-typescript-codegen"; |
5 | 6 |
|
6 | 7 | export type CLIOptions = { |
7 | | - outputDir: string; |
8 | | - path: string; |
9 | | -}; |
| 8 | + output?: string; |
| 9 | + client?: Options["httpClient"]; |
| 10 | +} & Pick<Options, 'exportSchemas' | 'postfix' | 'request' | 'indent' | 'input'>; |
10 | 11 |
|
11 | 12 | const program = new Command(); |
12 | 13 |
|
13 | 14 | program |
14 | | - .name('openapi-rq') |
| 15 | + .name("openapi-rq") |
15 | 16 | .version(packageJson.version) |
16 | 17 | .description("Generate React Query code based on OpenAPI") |
17 | | - .requiredOption("-p, --path <path>", "Path to OpenAPI file") |
| 18 | + .requiredOption( |
| 19 | + "-i, --input <value>", |
| 20 | + "OpenAPI specification, can be a path, url or string content (required)" |
| 21 | + ) |
| 22 | + .option("-o, --output <value>", "Output directory", "openapi") |
18 | 23 | .option( |
19 | | - "-o, --output-dir [directory]", |
20 | | - "Directory to output the generated package", |
21 | | - "openapi" |
| 24 | + "-c, --client <value>", |
| 25 | + "HTTP client to generate [fetch, xhr, node, axios, angular]", |
| 26 | + "fetch" |
22 | 27 | ) |
| 28 | + .option("--exportSchemas <value>", "Write schemas to disk", false) |
| 29 | + .option("--indent <value>", "Indentation options [4, 2, tabs]", "4") |
| 30 | + .option("--postfix <value>", "Service name postfix", "Service") |
| 31 | + .option("--request <value>", "Path to custom request file") |
23 | 32 | .parse(); |
24 | 33 |
|
25 | 34 | const options = program.opts<CLIOptions>(); |
26 | 35 |
|
27 | | -console.log(`Generating React Query code using OpenApi file ${options.path}`); |
| 36 | +console.log(`Generating React Query code using OpenApi file ${options.output}`); |
28 | 37 | generate(options); |
0 commit comments