@bashlife/boxbox-beta 69.0.0 → 70.0.0

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bashlife/boxbox-beta",
3
- "version": "69.0.0",
3
+ "version": "70.0.0",
4
4
  "description": "A modern BusyBox-style CLI toolkit with custom commands.",
5
5
  "type": "module",
6
6
  "author": "bashlife",
@@ -0,0 +1,49 @@
1
+ import fs from "fs";
2
+
3
+ export default async function(args) {
4
+ let decode = false;
5
+ let inputFile = null;
6
+ let outputFile = null;
7
+
8
+ for (let i = 0; i < args.length; i++) {
9
+ const arg = args[i];
10
+
11
+ if (arg === "-d" || arg === "--decode") {
12
+ decode = true;
13
+ } else if (arg === "-i" || arg === "--input") {
14
+ inputFile = args[++i];
15
+ } else if (arg === "-o" || arg === "--output") {
16
+ outputFile = args[++i];
17
+ }
18
+ }
19
+
20
+ try {
21
+ let input;
22
+
23
+ if (inputFile) {
24
+ input = fs.readFileSync(inputFile);
25
+ } else {
26
+ input = Buffer.from(
27
+ args.filter(a => !a.startsWith("-")).join(" "),
28
+ "utf8"
29
+ );
30
+ }
31
+
32
+ let result;
33
+
34
+ if (decode) {
35
+ result = Buffer.from(input.toString(), "base64");
36
+ } else {
37
+ result = Buffer.from(input).toString("base64");
38
+ }
39
+
40
+ if (outputFile) {
41
+ fs.writeFileSync(outputFile, result);
42
+ } else {
43
+ console.log(result.toString());
44
+ }
45
+
46
+ } catch (err) {
47
+ console.error(`base64: ${err.message}`);
48
+ }
49
+ }
package/src/index.js CHANGED
@@ -6,6 +6,7 @@ const args = process.argv.slice(2);
6
6
  const command = args[0];
7
7
 
8
8
  const commands = {
9
+ base64: "./commands/base64.js",
9
10
  rmdir: "./commands/rmdir.js",
10
11
  javascript: "./commands/JavaScriptRun/index.js",
11
12
  printf: "./commands/printf.js",
@@ -160,6 +161,8 @@ Commands:
160
161
  printf Format and print text
161
162
  javascript Run JavaScript projects with jsRun
162
163
  rmdir Remove empty directories
164
+ nano create files write them edit them
165
+ base64 Encode or decode data using Base64
163
166
  `);
164
167
 
165
168
  process.exit(0);