1+ /*
2+ * Copyright (c) 2025, salesforce.com, inc.
3+ * All rights reserved.
4+ * SPDX-License-Identifier: BSD-3-Clause
5+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
6+ */
7+
8+ import { Command , flags } from "@oclif/command" ;
9+ import { allCommonFlags } from "../common/flags" ;
10+ import { generateFromOas , DEFAULT_CONFIG_PACKAGE_PATH , DEFAULT_CONFIG_PATH } from "./generateFromOas" ;
11+
12+ export class GenerateCommand extends Command {
13+
14+ static description = "Generate from OAS" ;
15+
16+ static flags = {
17+ ...allCommonFlags ( ) ,
18+ inputSpec : flags . string ( {
19+ char : "i" ,
20+ description : 'Input OAS specification file' ,
21+ required : true ,
22+ } ) ,
23+ outputDir : flags . string ( {
24+ char : "o" ,
25+ description : 'Output directory for generated code' ,
26+ required : true ,
27+ } ) ,
28+ templateDir : flags . string ( {
29+ char : "t" ,
30+ description : 'Template directory' ,
31+ required : true ,
32+ } ) ,
33+ configFile : flags . string ( {
34+ char : "c" ,
35+ description : `[default:${ DEFAULT_CONFIG_PACKAGE_PATH } ] Configuration file with additional generator properties`
36+ } ) ,
37+ generator : flags . string ( {
38+ char : "g" ,
39+ description : '[default:typescript-fetch] Generator to use' ,
40+ } ) ,
41+ skipValidateSpec : flags . boolean ( {
42+ description : 'Skip validation of the OAS specification' ,
43+ } ) ,
44+ } ;
45+
46+ async run ( ) : Promise < void > {
47+ console . log ( 'Running generator' )
48+ const { flags } = this . parse ( GenerateCommand ) ;
49+ console . log ( flags )
50+ generateFromOas ( {
51+ inputSpec : flags . inputSpec ,
52+ outputDir : flags . outputDir ,
53+ templateDir : flags . templateDir ,
54+ configFile : flags . configFile ,
55+ generator : flags . generator ,
56+ skipValidateSpec : flags . skipValidateSpec
57+ } ) ;
58+ }
59+ }
0 commit comments