Skip to content

Commit 4d14115

Browse files
committed
feat(cli): Adding report flag
1 parent c91aa21 commit 4d14115

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

templates/cli/index.js.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ program
2828
.version(version, "-v, --version")
2929
.option("--verbose", "Show complete error log")
3030
.option("--json", "Output in JSON format")
31+
.option("--report", "Enable reporting when cli is crashing")
3132
.on("option:json", () => {
3233
cliConfig.json = true;
3334
})
3435
.on("option:verbose", () => {
3536
cliConfig.verbose = true;
3637
})
38+
.on("option:report", () => {
39+
cliConfig.report = true;
40+
})
3741
.showSuggestionAfterError()
3842
{% if sdk.test != "true" %}
3943
.addCommand(login)

templates/cli/lib/parser.js.twig

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ const { description } = require('../package.json');
55

66
const cliConfig = {
77
verbose: false,
8-
json: false
8+
json: false,
9+
report: false
910
};
1011

1112
const parse = (data) => {
@@ -110,12 +111,18 @@ const drawJSON = (data) => {
110111
}
111112

112113
const parseError = (err) => {
114+
if(cliConfig.report) {
115+
const githubIssueUrl=`https://github.com/appwrite/appwrite/issues/new?labels=bug&template=bug.yaml&title=%F0%9F%90%9B+Bug+Report%3A+&actual-behavior=Console%20Crash%0A${encodeURIComponent('```\n'+err.stack+'\n```').replaceAll('(','').replaceAll(')','')}`
116+
117+
log(`To report this error you can:\n - Create a support ticket in our Discord server https://appwrite.io/discord \n - Create an issue in our Github\n ${githubIssueUrl}\n`);
118+
}
119+
113120
if(cliConfig.verbose) {
114121
console.error(err);
122+
} else {
123+
error(err.message);
115124
}
116125

117-
error(err.message);
118-
119126
process.exit(1)
120127
}
121128

0 commit comments

Comments
 (0)