Skip to content

Commit

Permalink
[tsp-client] Add no-prompt flag (#8296)
Browse files Browse the repository at this point in the history
* add no-prompt flag

* document the flag

---------

Co-authored-by: Catalina Peralta <caperal@microsoft.com>
  • Loading branch information
catalinaperalta and cperaltah authored May 20, 2024
1 parent 93102e6 commit 2f5685c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions tools/tsp-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release

## 2024-05-20 - 0.7.1

- Added `--no-prompt` flag to skip the output directory confirmation prompt.

## 2024-04-18 - 0.7.0

- Remove `resources.json` after converting resource manager specifications.
Expand Down
1 change: 1 addition & 0 deletions tools/tsp-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Convert an existing swagger specification to a TypeSpec project. This command sh
an existing emitter-package.json [boolean]
-h, --help Show help [boolean]
--local-spec-repo Path to local repository with the TypeSpec project [string]
--no-prompt Skip prompting for output directory confirmation [boolean]
--save-inputs Don't clean up the temp directory after generation [boolean]
--skip-sync-and-generate Skip sync and generate during project init [boolean]
--swagger-readme Path or url to swagger readme file [string]
Expand Down
4 changes: 2 additions & 2 deletions tools/tsp-client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tools/tsp-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure-tools/typespec-client-generator-cli",
"version": "0.7.0",
"version": "0.7.1",
"description": "A tool to generate Azure SDKs from TypeSpec",
"main": "dist/index.js",
"homepage": "https://github.com/Azure/azure-sdk-tools/tree/main/tools/tsp-client#readme",
Expand Down
1 change: 1 addition & 0 deletions tools/tsp-client/src/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Options:
an existing emitter-package.json [boolean]
-h, --help Show help [boolean]
--local-spec-repo Path to local repository with the TypeSpec project [string]
--no-prompt Skip prompting for output directory confirmation [boolean]
--save-inputs Don't clean up the temp directory after generation [boolean]
--skip-sync-and-generate Skip sync and generate during project init [boolean]
--swagger-readme Path or url to swagger readme file [string]
Expand Down
11 changes: 9 additions & 2 deletions tools/tsp-client/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export async function getOptions(): Promise<Options> {
["local-spec-repo"]: {
type: "string",
},
["no-prompt"]: {
type: "boolean",
},
["save-inputs"]: {
type: "boolean",
},
Expand All @@ -72,7 +75,7 @@ export async function getOptions(): Promise<Options> {
},
arm: {
type: "boolean",
}
},
},
});
if (values.help) {
Expand Down Expand Up @@ -142,8 +145,12 @@ export async function getOptions(): Promise<Options> {
}
outputDir = resolvePath(process.cwd(), outputDir);

let noPrompt = false;
if (values["no-prompt"]) {
noPrompt = true;
}
let useOutputDir;
if (process.stdin.isTTY) {
if (process.stdin.isTTY && !noPrompt) {
// Ask user is this is the correct output directory
const prompt = PromptSync();
useOutputDir = prompt("Use output directory '" + outputDir + "'? (y/n) ", "y");
Expand Down

0 comments on commit 2f5685c

Please sign in to comment.