@egyptron/cease 1.0.1
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/.gitattributes +1 -0
- package/bin/main.js +50 -0
- package/examples/example_one.cease +2 -0
- package/examples/example_two.cease +5 -0
- package/index.js +63 -0
- package/package.json +37 -0
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.cease linguist-language=Cease
|
package/bin/main.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { runCease } from '../index.js';
|
|
5
|
+
|
|
6
|
+
const args = process.argv.slice(2);
|
|
7
|
+
|
|
8
|
+
async function start() {
|
|
9
|
+
if (args.length === 0) {
|
|
10
|
+
console.log('Usage: cease "URL" --t "msg" OR cease "URL" --e');
|
|
11
|
+
process.exitCode = 1;
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 1. Version Check
|
|
16
|
+
if (args[0] === '--v' || args[0] === '-v') {
|
|
17
|
+
const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)));
|
|
18
|
+
console.log(`Cease version: ${pkg.version}`);
|
|
19
|
+
process.exitCode = 0;
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// 2. Direct Command Mode (Check if the FIRST argument is a URL)
|
|
24
|
+
if (args[0].startsWith('http')) {
|
|
25
|
+
const url = args[0];
|
|
26
|
+
const flag = args[1]; // The flag (like --t or --e)
|
|
27
|
+
const message = args.slice(2).join(' '); // Everything after the flag
|
|
28
|
+
|
|
29
|
+
const fullCommand = `cease "${url}" ${flag || '--t'} "${message}"`;
|
|
30
|
+
|
|
31
|
+
// If flag is --e, we tell index.js to go INTERACTIVE (true)
|
|
32
|
+
const isInteractive = (flag === '--e');
|
|
33
|
+
await runCease(fullCommand, isInteractive);
|
|
34
|
+
process.exitCode = 0;
|
|
35
|
+
}
|
|
36
|
+
// 3. File Mode
|
|
37
|
+
else {
|
|
38
|
+
try {
|
|
39
|
+
const fullPath = path.resolve(process.cwd(), args[0]);
|
|
40
|
+
const sourceCode = fs.readFileSync(fullPath, 'utf8');
|
|
41
|
+
await runCease(sourceCode, false);
|
|
42
|
+
process.exitCode = 0;
|
|
43
|
+
} catch (err) {
|
|
44
|
+
console.error(`Error: ${err.message}`);
|
|
45
|
+
process.exitCode = 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
start();
|
package/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import readline from 'node:readline/promises';
|
|
2
|
+
import { stdin as input, stdout as output } from 'node:process';
|
|
3
|
+
|
|
4
|
+
export async function runCease(code, isInteractive = false) {
|
|
5
|
+
const lines = code.split('\n').map(l => l.trim()).filter(l => l.length > 0);
|
|
6
|
+
|
|
7
|
+
for (let i = 0; i < lines.length; i++) {
|
|
8
|
+
const line = lines[i];
|
|
9
|
+
if (line.startsWith('cease')) {
|
|
10
|
+
await handleWebhook(line, lines.slice(i), isInteractive);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function handleWebhook(line, remainingLines, isInteractive) {
|
|
16
|
+
const match = line.match(/^cease ["]?([^" ]+)["]?\s+(--\w+)(?:\s+["]?([^"]+)["]?)?/);
|
|
17
|
+
if (!match) return;
|
|
18
|
+
|
|
19
|
+
const [_, url, flag, inlineText] = match;
|
|
20
|
+
let payload = {};
|
|
21
|
+
|
|
22
|
+
if (flag === '--t') {
|
|
23
|
+
payload = { content: inlineText || "No message provided." };
|
|
24
|
+
}
|
|
25
|
+
else if (flag === '--e') {
|
|
26
|
+
let embed = { title: "", description: "", color: 5814783 };
|
|
27
|
+
|
|
28
|
+
if (isInteractive) {
|
|
29
|
+
// INTERACTIVE MODE (Terminal)
|
|
30
|
+
const rl = readline.createInterface({ input, output });
|
|
31
|
+
console.log("\n--- Cease Embed Builder ---");
|
|
32
|
+
embed.title = await rl.question('Title: ');
|
|
33
|
+
embed.description = await rl.question('Description: ');
|
|
34
|
+
const hex = await rl.question('Color (HEX, e.g. #ff0000): ');
|
|
35
|
+
if (hex) embed.color = parseInt(hex.replace('#', ''), 16);
|
|
36
|
+
rl.close();
|
|
37
|
+
} else {
|
|
38
|
+
// FILE MODE (Reading hello.ce)
|
|
39
|
+
for (const l of remainingLines) {
|
|
40
|
+
if (l.startsWith('Title:')) embed.title = l.replace('Title:', '').trim();
|
|
41
|
+
if (l.startsWith('Desc:')) embed.description = l.replace('Desc:', '').trim();
|
|
42
|
+
if (l.startsWith('Color:')) embed.color = parseInt(l.replace('Color:', '').trim().replace('#', ''), 16);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
payload = { embeds: [embed] };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
await sendToDiscord(url, payload);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function sendToDiscord(url, payload) {
|
|
52
|
+
try {
|
|
53
|
+
const res = await fetch(url, {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: { 'Content-Type': 'application/json' },
|
|
56
|
+
body: JSON.stringify(payload)
|
|
57
|
+
});
|
|
58
|
+
if (res.ok) console.log("✅ Cease: Dispatch successful.");
|
|
59
|
+
else console.error(`❌ Discord Error: ${res.status}`);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.error("❌ Network Error: Check your URL.");
|
|
62
|
+
}
|
|
63
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@egyptron/cease",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Cease is a lightweight and fast programming language, mainly used for Discord Webhooks.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public",
|
|
8
|
+
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
},
|
|
10
|
+
"main": "index.js",
|
|
11
|
+
"bin": {
|
|
12
|
+
"cease": "./bin/main.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "node test.js"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"programming-language",
|
|
19
|
+
"interpreter",
|
|
20
|
+
"cease",
|
|
21
|
+
"parser",
|
|
22
|
+
"cli"
|
|
23
|
+
],
|
|
24
|
+
"author": "Valo Digital, Co.",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/egyptron/cease.git"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/egyptron/cease/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/egyptron/cease#readme",
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"git": "^0.1.5"
|
|
36
|
+
}
|
|
37
|
+
}
|