product-discovery-cli 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/config/cliOptions.js
CHANGED
|
@@ -2,13 +2,19 @@ const { Command } = require("commander");
|
|
|
2
2
|
const { getTranslator } = require("../infrastructure/i18n");
|
|
3
3
|
|
|
4
4
|
function buildOptions(defaultApiUrl) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// First pass: get lang to determine i18n
|
|
6
|
+
const preProgram = new Command();
|
|
7
|
+
preProgram
|
|
8
|
+
.allowUnknownOption()
|
|
9
|
+
.option("-l, --lang <language>", "Language code (pt-br, en-us)", "pt-br");
|
|
10
|
+
|
|
11
|
+
preProgram.parse(process.argv);
|
|
12
|
+
const preOpts = preProgram.opts();
|
|
8
13
|
const i18n = getTranslator(preOpts.lang || "pt-br");
|
|
9
14
|
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
// Second pass: full options with translations
|
|
16
|
+
const program = new Command();
|
|
17
|
+
program
|
|
12
18
|
.name("product-discovery")
|
|
13
19
|
.description(i18n.t("cliDescription"))
|
|
14
20
|
.option("-u, --api-url <url>", i18n.t("optApiUrl"), defaultApiUrl)
|
|
@@ -19,8 +25,8 @@ function buildOptions(defaultApiUrl) {
|
|
|
19
25
|
.option("-f, --file <name>", i18n.t("optFile"))
|
|
20
26
|
.option("--no-save", i18n.t("optNoSave"));
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
return
|
|
28
|
+
program.parse(process.argv);
|
|
29
|
+
return program.opts();
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
module.exports = { buildOptions };
|
package/src/index.js
CHANGED
|
@@ -57,6 +57,21 @@ class ConsolePresenter {
|
|
|
57
57
|
spinner(text) {
|
|
58
58
|
return ora(text).start();
|
|
59
59
|
}
|
|
60
|
-
}
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
goodbye() {
|
|
62
|
+
if (!this.i18n) return;
|
|
63
|
+
output.write("\n");
|
|
64
|
+
output.write(
|
|
65
|
+
boxen(
|
|
66
|
+
`${chalk.bold.cyan(this.i18n.t("thankYou"))}\n${chalk.gray(this.i18n.t("closeConsole"))}`,
|
|
67
|
+
{
|
|
68
|
+
padding: 1,
|
|
69
|
+
margin: 1,
|
|
70
|
+
borderStyle: "round",
|
|
71
|
+
borderColor: "cyan"
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
);
|
|
75
|
+
output.write("\n");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -36,7 +36,11 @@ const translations = {
|
|
|
36
36
|
configError: "Erro no config:",
|
|
37
37
|
|
|
38
38
|
// Validation
|
|
39
|
-
required: "Este campo é obrigatório"
|
|
39
|
+
required: "Este campo é obrigatório",
|
|
40
|
+
|
|
41
|
+
// Goodbye
|
|
42
|
+
thankYou: "Obrigado por usar o Product Discovery CLI!",
|
|
43
|
+
closeConsole: "Você pode fechar esta janela ou pressionar Ctrl+C"
|
|
40
44
|
},
|
|
41
45
|
|
|
42
46
|
"en-us": {
|
|
@@ -76,7 +80,11 @@ const translations = {
|
|
|
76
80
|
configError: "Config error:",
|
|
77
81
|
|
|
78
82
|
// Validation
|
|
79
|
-
required: "This field is required"
|
|
83
|
+
required: "This field is required",
|
|
84
|
+
|
|
85
|
+
// Goodbye
|
|
86
|
+
thankYou: "Thank you for using Product Discovery CLI!",
|
|
87
|
+
closeConsole: "You can close this window or press Ctrl+C"
|
|
80
88
|
}
|
|
81
89
|
};
|
|
82
90
|
|