Skip to content

Commit 2f5685c

Browse files
[tsp-client] Add no-prompt flag (#8296)
* add no-prompt flag * document the flag --------- Co-authored-by: Catalina Peralta <caperal@microsoft.com>
1 parent 93102e6 commit 2f5685c

6 files changed

Lines changed: 18 additions & 5 deletions

File tree

tools/tsp-client/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release
22

3+
## 2024-05-20 - 0.7.1
4+
5+
- Added `--no-prompt` flag to skip the output directory confirmation prompt.
6+
37
## 2024-04-18 - 0.7.0
48

59
- Remove `resources.json` after converting resource manager specifications.

tools/tsp-client/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ Convert an existing swagger specification to a TypeSpec project. This command sh
5656
an existing emitter-package.json [boolean]
5757
-h, --help Show help [boolean]
5858
--local-spec-repo Path to local repository with the TypeSpec project [string]
59+
--no-prompt Skip prompting for output directory confirmation [boolean]
5960
--save-inputs Don't clean up the temp directory after generation [boolean]
6061
--skip-sync-and-generate Skip sync and generate during project init [boolean]
6162
--swagger-readme Path or url to swagger readme file [string]

tools/tsp-client/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/tsp-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@azure-tools/typespec-client-generator-cli",
3-
"version": "0.7.0",
3+
"version": "0.7.1",
44
"description": "A tool to generate Azure SDKs from TypeSpec",
55
"main": "dist/index.js",
66
"homepage": "https://github.com/Azure/azure-sdk-tools/tree/main/tools/tsp-client#readme",

tools/tsp-client/src/log.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ Options:
7979
an existing emitter-package.json [boolean]
8080
-h, --help Show help [boolean]
8181
--local-spec-repo Path to local repository with the TypeSpec project [string]
82+
--no-prompt Skip prompting for output directory confirmation [boolean]
8283
--save-inputs Don't clean up the temp directory after generation [boolean]
8384
--skip-sync-and-generate Skip sync and generate during project init [boolean]
8485
--swagger-readme Path or url to swagger readme file [string]

tools/tsp-client/src/options.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ export async function getOptions(): Promise<Options> {
6161
["local-spec-repo"]: {
6262
type: "string",
6363
},
64+
["no-prompt"]: {
65+
type: "boolean",
66+
},
6467
["save-inputs"]: {
6568
type: "boolean",
6669
},
@@ -72,7 +75,7 @@ export async function getOptions(): Promise<Options> {
7275
},
7376
arm: {
7477
type: "boolean",
75-
}
78+
},
7679
},
7780
});
7881
if (values.help) {
@@ -142,8 +145,12 @@ export async function getOptions(): Promise<Options> {
142145
}
143146
outputDir = resolvePath(process.cwd(), outputDir);
144147

148+
let noPrompt = false;
149+
if (values["no-prompt"]) {
150+
noPrompt = true;
151+
}
145152
let useOutputDir;
146-
if (process.stdin.isTTY) {
153+
if (process.stdin.isTTY && !noPrompt) {
147154
// Ask user is this is the correct output directory
148155
const prompt = PromptSync();
149156
useOutputDir = prompt("Use output directory '" + outputDir + "'? (y/n) ", "y");

0 commit comments

Comments
 (0)