turkiyem 1.10.0 → 1.10.2
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/commands/menu.js +74 -21
- package/src/utils/banner.js +14 -11
package/package.json
CHANGED
package/src/commands/menu.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import
|
|
2
|
+
import readline from 'node:readline';
|
|
3
3
|
import { printBanner } from '../utils/banner.js';
|
|
4
4
|
import { getCity } from '../utils/config.js';
|
|
5
5
|
|
|
@@ -13,39 +13,92 @@ function printSessionHeader() {
|
|
|
13
13
|
console.log('');
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
const commands = [
|
|
17
|
+
'sehir', 'hat', 'durak', 'hava', 'deprem', 'eczane', 'doviz', 'temizle', 'help', 'clear', 'exit', 'çıkış'
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
const subcommands = {
|
|
21
|
+
'sehir': ['ankara', 'istanbul', 'adana', 'antalya', 'bursa', 'izmir', 'trabzon', 'samsun'],
|
|
22
|
+
'hat': ['canli'],
|
|
23
|
+
'hava': ['guncel', 'saatlik', 'kalite'],
|
|
24
|
+
'deprem': ['son24', '7gun', 'buyukluk'],
|
|
25
|
+
'eczane': ['nobetci', 'ara']
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function completer(line) {
|
|
29
|
+
const parts = line.trimStart().split(/\s+/);
|
|
30
|
+
let completions = [];
|
|
31
|
+
|
|
32
|
+
if (parts.length === 1) {
|
|
33
|
+
completions = commands.filter(c => c.startsWith(parts[0]));
|
|
34
|
+
if (completions.length > 0) return [completions, line];
|
|
35
|
+
} else if (parts.length === 2) {
|
|
36
|
+
const cmd = parts[0];
|
|
37
|
+
if (subcommands[cmd]) {
|
|
38
|
+
const subCompletions = subcommands[cmd].filter(c => c.startsWith(parts[1]));
|
|
39
|
+
if (subCompletions.length > 0) {
|
|
40
|
+
const prefix = line.substring(0, line.length - parts[1].length);
|
|
41
|
+
const mappedCompletions = subCompletions.map(c => prefix + c);
|
|
42
|
+
return [mappedCompletions, line];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return [[], line];
|
|
48
|
+
}
|
|
49
|
+
|
|
16
50
|
export async function showMenu() {
|
|
51
|
+
console.clear();
|
|
17
52
|
printBanner();
|
|
18
53
|
console.log(chalk.white.bold(' 🇹🇷 Sürekli oturum modu — Komutları direkt yazabilirsiniz (Örn: hat 500T, deprem son24)\n'));
|
|
19
54
|
console.log(chalk.gray(' Tüm komutları görmek için "help" yazabilirsiniz.\n'));
|
|
20
55
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
56
|
+
const rl = readline.createInterface({
|
|
57
|
+
input: process.stdin,
|
|
58
|
+
output: process.stdout,
|
|
59
|
+
completer: completer,
|
|
60
|
+
prompt: chalk.cyan('turkiyem > '),
|
|
61
|
+
historySize: 200 // Yukarı/aşağı ok tuşu arabellek boyutu
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
printSessionHeader();
|
|
65
|
+
rl.prompt();
|
|
24
66
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
name: 'cmd',
|
|
28
|
-
message: chalk.cyan('turkiyem >')
|
|
29
|
-
});
|
|
67
|
+
rl.on('line', async (line) => {
|
|
68
|
+
const cmd = line.trim();
|
|
30
69
|
|
|
31
|
-
if (cmd
|
|
70
|
+
if (cmd.toLowerCase() === 'exit' || cmd.toLowerCase() === 'çıkış') {
|
|
32
71
|
console.log('');
|
|
33
72
|
console.log(chalk.cyan(' Görüşmek üzere! 🇹🇷👋'));
|
|
34
73
|
console.log('');
|
|
35
|
-
|
|
74
|
+
rl.close();
|
|
75
|
+
return;
|
|
36
76
|
}
|
|
37
77
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
78
|
+
if (cmd.toLowerCase() === 'clear') {
|
|
79
|
+
console.clear();
|
|
80
|
+
printBanner();
|
|
81
|
+
console.log(chalk.white.bold(' 🇹🇷 Sürekli oturum modu — Komutları direkt yazabilirsiniz (Örn: hat 500T, deprem son24)\n'));
|
|
82
|
+
console.log(chalk.gray(' Tüm komutları görmek için "help" yazabilirsiniz.\n'));
|
|
83
|
+
printSessionHeader();
|
|
84
|
+
rl.prompt();
|
|
85
|
+
return;
|
|
42
86
|
}
|
|
43
87
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
88
|
+
const args = cmd.split(' ').filter(Boolean);
|
|
89
|
+
|
|
90
|
+
if (args.length > 0) {
|
|
91
|
+
try {
|
|
92
|
+
const { spawnSync } = await import('node:child_process');
|
|
93
|
+
spawnSync(process.argv[0], [process.argv[1], ...args], { stdio: 'inherit' });
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.log(chalk.red(`\n Komut çalıştırılamadı: ${err.message}`));
|
|
96
|
+
}
|
|
49
97
|
}
|
|
50
|
-
|
|
98
|
+
|
|
99
|
+
printSessionHeader();
|
|
100
|
+
rl.prompt();
|
|
101
|
+
}).on('close', () => {
|
|
102
|
+
process.exit(0);
|
|
103
|
+
});
|
|
51
104
|
}
|
package/src/utils/banner.js
CHANGED
|
@@ -24,17 +24,20 @@ export function printBanner() {
|
|
|
24
24
|
export function printHelp() {
|
|
25
25
|
printBanner();
|
|
26
26
|
console.log(chalk.white.bold(' Komutlar:\n'));
|
|
27
|
-
console.log(chalk.cyan(' turkiyem sehir <ankara|istanbul>') + chalk.gray('
|
|
27
|
+
console.log(chalk.cyan(' turkiyem sehir <ankara|istanbul|adana|antalya|bursa|izmir|trabzon|samsun>') + chalk.gray('\n Şehir seç'));
|
|
28
28
|
console.log(chalk.cyan(' turkiyem hat <numara>') + chalk.gray(' Hat sorgula'));
|
|
29
|
-
console.log(chalk.cyan(' turkiyem hat canli <numara> [--detay]') + chalk.gray('
|
|
30
|
-
console.log(chalk.cyan(' turkiyem
|
|
31
|
-
console.log(chalk.cyan(' turkiyem hava
|
|
32
|
-
console.log(chalk.cyan(' turkiyem hava
|
|
33
|
-
console.log(chalk.cyan(' turkiyem
|
|
34
|
-
console.log(chalk.cyan(' turkiyem deprem
|
|
35
|
-
console.log(chalk.cyan(' turkiyem deprem
|
|
36
|
-
console.log(chalk.cyan(' turkiyem
|
|
37
|
-
console.log(chalk.cyan(' turkiyem
|
|
38
|
-
console.log(chalk.cyan(' turkiyem
|
|
29
|
+
console.log(chalk.cyan(' turkiyem hat canli <numara> [--detay]') + chalk.gray(' Canlı araç konumu (IETT)'));
|
|
30
|
+
console.log(chalk.cyan(' turkiyem durak <id>') + chalk.gray(' Durak bazlı detay sorgula'));
|
|
31
|
+
console.log(chalk.cyan(' turkiyem hava guncel [sehir|lat,lon]') + chalk.gray(' Güncel hava durumu'));
|
|
32
|
+
console.log(chalk.cyan(' turkiyem hava saatlik [sehir|lat,lon] -g 2') + chalk.gray(' Saatlik hava tahmini'));
|
|
33
|
+
console.log(chalk.cyan(' turkiyem hava kalite [sehir|lat,lon]') + chalk.gray(' Hava kalitesi ölçümleri'));
|
|
34
|
+
console.log(chalk.cyan(' turkiyem deprem son24') + chalk.gray(' Son 24 saatteki depremler'));
|
|
35
|
+
console.log(chalk.cyan(' turkiyem deprem 7gun') + chalk.gray(' Son 7 gündeki depremler'));
|
|
36
|
+
console.log(chalk.cyan(' turkiyem deprem buyukluk <deger>') + chalk.gray(' Büyüklüğe göre deprem filtrele'));
|
|
37
|
+
console.log(chalk.cyan(' turkiyem eczane nobetci [ilce]') + chalk.gray(' Nöbetçi eczaneleri sorgula'));
|
|
38
|
+
console.log(chalk.cyan(' turkiyem eczane ara <kelime>') + chalk.gray(' Eczane adına veya ilçeye göre ara'));
|
|
39
|
+
console.log(chalk.cyan(' turkiyem doviz [--tum]') + chalk.gray(' TCMB güncel döviz kurları'));
|
|
40
|
+
console.log(chalk.cyan(' turkiyem temizle') + chalk.gray(' Cache ve ayarları temizle'));
|
|
41
|
+
console.log(chalk.cyan(' turkiyem --version') + chalk.gray(' Versiyonu göster'));
|
|
39
42
|
console.log('');
|
|
40
43
|
}
|