privacy-brush 0.0.3 → 0.0.4
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 +1 -1
- package/src/cli.mjs +43 -5
package/package.json
CHANGED
package/src/cli.mjs
CHANGED
|
@@ -45,6 +45,11 @@ const [err, result] = safeCall(() =>
|
|
|
45
45
|
verbose: {
|
|
46
46
|
type: "boolean",
|
|
47
47
|
},
|
|
48
|
+
// version
|
|
49
|
+
version: {
|
|
50
|
+
type: "boolean",
|
|
51
|
+
short: "v",
|
|
52
|
+
},
|
|
48
53
|
},
|
|
49
54
|
}),
|
|
50
55
|
)
|
|
@@ -55,16 +60,22 @@ async function main() {
|
|
|
55
60
|
if (err) {
|
|
56
61
|
console.error(verbose ? err : String(err))
|
|
57
62
|
console.error()
|
|
58
|
-
printHelp()
|
|
63
|
+
await printHelp()
|
|
59
64
|
|
|
60
65
|
process.exit(1)
|
|
66
|
+
return
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
const { values } = result
|
|
64
70
|
|
|
65
71
|
if (values.help) {
|
|
66
|
-
printHelp()
|
|
67
|
-
|
|
72
|
+
await printHelp()
|
|
73
|
+
return
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (values.version) {
|
|
77
|
+
await printVersion()
|
|
78
|
+
return
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
// console.log("values:", values)
|
|
@@ -104,13 +115,40 @@ function safeCall(fn) {
|
|
|
104
115
|
}
|
|
105
116
|
}
|
|
106
117
|
|
|
107
|
-
function printHelp() {
|
|
108
|
-
console.log(`
|
|
118
|
+
async function printHelp() {
|
|
119
|
+
console.log(`
|
|
120
|
+
${await getNameVersion()}
|
|
121
|
+
|
|
122
|
+
Usage: pnpx privacy-brush [options]
|
|
109
123
|
|
|
110
124
|
Options:
|
|
111
125
|
--mask, -m Character to use for masking (default: "█")
|
|
112
126
|
--preserve-first, -p Whether to preserve the first part of version numbers (default: true, \`--no-preserve-first\` to false)
|
|
113
127
|
--help, -h Show this help message (default: false)
|
|
114
128
|
--verbose Enable verbose output (default: false)
|
|
129
|
+
--version, -v Show version information (default: false)
|
|
130
|
+
|
|
131
|
+
Examples:
|
|
132
|
+
echo "Microsoft Windows [Version 10.0.12345.6785]" | pnpx privacy-brush
|
|
133
|
+
echo "Microsoft Windows [Version 10.0.12345.6785]" | pnpx privacy-brush --mask "X" --no-preserve-first
|
|
115
134
|
`)
|
|
116
135
|
}
|
|
136
|
+
|
|
137
|
+
async function parsePackageJSON() {
|
|
138
|
+
const fs = await import("node:fs")
|
|
139
|
+
const pkgPath = new URL("../package.json", import.meta.url)
|
|
140
|
+
|
|
141
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"))
|
|
142
|
+
|
|
143
|
+
return pkg
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async function getNameVersion() {
|
|
147
|
+
const pkg = await parsePackageJSON()
|
|
148
|
+
|
|
149
|
+
return `${pkg.name}@${pkg.version}`
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async function printVersion() {
|
|
153
|
+
console.log(await getNameVersion())
|
|
154
|
+
}
|