Skip to content

Commit 3d827df

Browse files
author
ljacobsson
committed
Adding new command: describe
1 parent 6561f6e commit 3d827df

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sam-patterns-cli",
3-
"version": "0.0.42",
3+
"version": "0.0.43",
44
"description": "Command line interface for quickly using patterns from https://github.com/aws-samples/serverless-patterns/",
55
"main": "index.js",
66
"scripts": {

src/commands/describe/describe.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ async function run(cmd) {
5252
}
5353
}
5454
path += "/" + cmd.template;
55+
try {
5556
template = await githubUtil.getContent(owner, repo, path);
57+
} catch (e) {
58+
console.log("Couldn't find " + cmd.template + " in " + cmd.repositoryPath);
59+
return;
60+
}
5661
}
5762
const configuration = new Configuration({
5863
apiKey,
@@ -87,10 +92,16 @@ async function run(cmd) {
8792
max_tokens: 1000
8893
};
8994
spinner.start();
95+
try {
96+
9097
const response = await openai.createChatCompletion(openAiRequest);
9198
spinner.stop();
9299
let text = response.data.choices[0].message.content;
93100
console.log(`\n\n${text}`);
101+
} catch (error) {
102+
spinner.stop();
103+
console.log("\n\n" + error.response.data.error.message);
104+
}
94105

95106

96107
}

0 commit comments

Comments
 (0)