Skip to content

Commit

Permalink
Merge pull request #1066 from pmcelhaney/clean-up-options
Browse files Browse the repository at this point in the history
  • Loading branch information
pmcelhaney authored Oct 3, 2024
2 parents d4140c7 + c5d5774 commit a921a22
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-crews-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"counterfact": minor
---

minor change to REPL: if no action-related argument is passed (--generate, --watch, --serve, --repl), do all of the actions
20 changes: 12 additions & 8 deletions bin/counterfact.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ async function main(source, destination) {
debug("executing the main function");

const options = program.opts();

const args = process.argv;

const destinationPath = nodePath
Expand All @@ -108,12 +109,17 @@ async function main(source, destination) {

const basePath = nodePath.resolve(destinationPath).replaceAll("\\", "/");

// If no options are provided, default to all options
if (!args.some((argument) => argument.startsWith("-"))) {
options.repl = true;
options.serve = true;
options.watch = true;
options.generate = true;
// If no action-related option is provided, default to all options

const actions = ["repl", "serve", "watch", "generate"];
if (
!Object.keys(options).some((argument) =>
actions.some((action) => argument.startsWith(action)),
)
) {
for (const action of actions) {
options[action] = true;
}
}

debug("options: %o", options);
Expand Down Expand Up @@ -145,7 +151,6 @@ async function main(source, destination) {
options.watchTypes,
},

includeSwaggerUi: true,
openApiPath: source,
port: options.port,
proxyPaths: new Map([["", Boolean(options.proxyUrl)]]),
Expand Down Expand Up @@ -248,7 +253,6 @@ program
)
.argument("[destination]", "path to generated code", ".")
.option("-p, --port <number>", "server port number", DEFAULT_PORT)
.option("--swagger", "include swagger-ui")
.option("-o, --open", "open a browser")
.option("-g, --generate", "generate all code for both routes and types")
.option("--generate-types", "generate types")
Expand Down
1 change: 0 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ This command will generate TypeScript code for the Swagger Pet Store and start t
>
> Options:
> --port <number> server port number (default: 3100)
> --swagger include swagger-ui
> -o, --open open a browser
> -g, --generate generate all code for both routes and types
> --generate-types generate types
Expand Down

0 comments on commit a921a22

Please sign in to comment.