|
1
|
#! /usr/bin/env node |
|
2
|
|
|
3
|
import { Command } from "commander" |
|
4
|
import { getCommand as oasGetCommand } from "./command-oas" |
|
5
|
import { getCommand as docsGetCommand } from "./command-docs" |
|
6
|
|
|
7
|
const run = async () => { |
|
8
|
const program = getBaseCommand() |
|
9
|
|
|
10
|
/** |
|
11
|
* Alias to command-oas.ts |
|
12
|
*/ |
|
13
|
program.addCommand(oasGetCommand()) |
|
14
|
|
|
15
|
/** |
|
16
|
* Alias to command-docs.ts |
|
17
|
*/ |
|
18
|
program.addCommand(docsGetCommand()) |
|
19
|
|
|
20
|
/** |
|
21
|
* Run CLI |
|
22
|
*/ |
|
23
|
await program.parseAsync() |
|
24
|
} |
|
25
|
|
|
26
|
export function getBaseCommand() { |
|
27
|
const command = new Command() |
|
28
|
command.name("medusa-oas") |
|
29
|
command.action(async () => { |
|
30
|
console.log("No command provided.") |
|
31
|
command.outputHelp({ error: true }) |
|
32
|
}) |
|
33
|
command.showHelpAfterError(true) |
|
34
|
command.helpOption(false) |
|
35
|
return command |
|
36
|
} |
|
37
|
|
|
38
|
void (async () => { |
|
39
|
await run() |
|
40
|
})() |