1
1
// Неообходимые библиотеки/модули
2
- #include " winPulsar.h"
2
+ #include " C:\Users\user\Desktop\PulsarVenv Main\public\source\WindowsPulsar\ winPulsar.h"
3
3
#include < atomic>
4
4
#include < chrono>
5
5
#include < cstdlib>
15
15
#include < cctype>
16
16
#include " C:\Users\user\source\repos\PulsarVenv\PulsarVenv\pulsFileSystem.h"
17
17
18
+ // Макросы цветов
19
+ #define CLEAR " \x1b [0m"
20
+ #define RED " \x1b [31m"
21
+ #define GREEN " \x1b [32m"
22
+ #define BOLD " \x1b [1m"
23
+
18
24
// Пространство имен std
19
25
using namespace std ;
20
26
@@ -24,7 +30,6 @@ string current_path;
24
30
string build_ID;
25
31
string style = " " ;
26
32
bool isLog = true ;
27
- bool isError = true ;
28
33
atomic<bool > timeThreadRunning (true );
29
34
mutex consoleMutex;
30
35
@@ -82,7 +87,7 @@ class CurrentPulsarInfo {
82
87
};
83
88
84
89
// Реализация статический переменных class CurrentPulsarInfo
85
- string CurrentPulsarInfo::title = " PulsarVenv 0.2.5 " ;
90
+ string CurrentPulsarInfo::title = " PulsarVenv 0.3.0 " ;
86
91
string CurrentPulsarInfo::platform_version = " Windows" ;
87
92
string CurrentPulsarInfo::account = " " ;
88
93
int CurrentPulsarInfo::start_time = 0 ;
@@ -212,35 +217,7 @@ void puls_sysconfig(string line) {
212
217
}
213
218
214
219
void show_help () {
215
- cout << " PulsarVenv 0.0.1-alpha - Справочник по командам" << endl << endl;
216
-
217
- cout << " Основные команды:" << endl;
218
- cout << " =================" << endl;
219
- cout << " help - Показать эту справку" << endl;
220
- cout << " exit - Выйти из системы" << endl;
221
- cout << " clear - Очистить экран консоли" << endl;
222
- cout << " pinfo - Показать информацию о Pulsar (версия, время работы и т.д.)" << endl << endl;
223
- cout << " chemdb - Химическая база данных" << endl << endl;
224
-
225
- cout << " Команды работы с системой:" << endl;
226
- cout << " =========================" << endl;
227
- cout << " sysconfig - Показать конфигурацию системы" << endl;
228
- cout << " sumulator_pulsar - Запустить эмуляцию пульсара (требует подтверждения)" << endl << endl;
229
-
230
- cout << " Команды для вычислений:" << endl;
231
- cout << " =======================" << endl;
232
- cout << " calc <выражение> - Выполнить математическое вычисление (например: calc 2+2*3)" << endl << endl;
233
-
234
- cout << " Управление аккаунтами:" << endl;
235
- cout << " =====================" << endl;
236
- cout << " account add - Создать новый аккаунт" << endl;
237
- cout << " account remove - Удалить существующий аккаунт" << endl;
238
- cout << " account swap - Сменить текущий аккаунт" << endl << endl;
239
-
240
- cout << " Запуск программ:" << endl;
241
- cout << " ===============" << endl;
242
- cout << " <имя_программы> - Запустить программу из папки modules" << endl;
243
- cout << " (можно указывать с расширением .exe или без)" << endl;
220
+ cout << " Справочник по командам - https://github.com/PulsarPrograms/PulsarVenv/wiki" << endl << endl;
244
221
}
245
222
246
223
int PulsarConsoleClear () {
@@ -538,14 +515,6 @@ int comAnalyze(string line) {
538
515
else if (line.substr (0 , 12 ) == " change style" ) {
539
516
changeStyle ();
540
517
}
541
- else if (line.starts_with (" -error" )) {
542
- cout << " Сообщения об ошибках выключены" << endl;
543
- isError = false ;
544
- }
545
- else if (line.starts_with (" +error" )) {
546
- cout << " Сообщения об ошибках включены" << endl;
547
- isError = true ;
548
- }
549
518
else if (line == " chemdb" ) {
550
519
string pathToChemBd = " cd " + current_path + " \\ SystemPuls\\ systemmodules && chembd.exe" ;
551
520
system (pathToChemBd.c_str ());
@@ -591,6 +560,51 @@ int comAnalyze(string line) {
591
560
}
592
561
}
593
562
}
563
+ else if (line.starts_with (" write" )) {
564
+ line.erase (0 , 5 );
565
+ line.erase (0 , line.find_first_not_of (' ' ));
566
+
567
+ if (line.empty () || line[0 ] != ' "' ) {
568
+ cout << RED << BOLD << " Ошибка: ожидается '\" ' в начале строки" << CLEAR << endl;
569
+ return 1 ;
570
+ }
571
+
572
+ string log_message;
573
+ bool quote_closed = false ;
574
+ int i = 1 ;
575
+
576
+ for (; i < line.length (); i++) {
577
+ if (line[i] == ' "' ) {
578
+ quote_closed = true ;
579
+ i++;
580
+ break ;
581
+ }
582
+ log_message += line[i];
583
+ }
584
+
585
+ if (!quote_closed) {
586
+ cout << RED << BOLD << " Ошибка: незакрытый строковый литерал" << CLEAR << endl;
587
+ return 1 ;
588
+ }
589
+
590
+ line.erase (0 , i);
591
+ line.erase (0 , line.find_first_not_of (' ' ));
592
+
593
+ bool add_time = false ;
594
+ if (line.starts_with (" +time" )) {
595
+ add_time = true ;
596
+ line.erase (0 , 5 );
597
+ line.erase (0 , line.find_first_not_of (' ' ));
598
+ }
599
+
600
+ for (char c : line) {
601
+ if (!isspace (c)) {
602
+ cout << RED << BOLD << " Ошибка: неожиданные символы после команды: '" << c << " '" << CLEAR << endl;
603
+ return 1 ;
604
+ }
605
+ }
606
+ writeInLog (log_message, add_time, false );
607
+ }
594
608
595
609
else {
596
610
cout << " Неопознанная log-команда" << endl;
@@ -615,7 +629,7 @@ int comAnalyze(string line) {
615
629
system (cdmodule.c_str ());
616
630
}
617
631
else {
618
- if (isError) cout << " Ошибка: Команда не распознана. Введите 'help' для справки." << endl;
632
+ cout << RED << " Ошибка: Команда не распознана. Введите 'help' для справки." << CLEAR << endl;
619
633
}
620
634
}
621
635
}
@@ -651,7 +665,7 @@ int pulsStarterScript() {
651
665
fstream scrsFile;
652
666
scrsFile.open (current_path + " \\ accounts\\ " + CurrentPulsarInfo::account + " \\ startscript.txt" , fstream::in | fstream::out | ios::app);
653
667
if (!scrsFile.is_open ()) {
654
- cout << " Ошибка работы с файлом - " << current_path + " \\ accounts\\ " + CurrentPulsarInfo::account + " \\ startscript.txt" << endl;
668
+ cout << RED << " Ошибка работы с файлом - " << current_path + " \\ accounts\\ " + CurrentPulsarInfo::account + " \\ startscript.txt" << CLEAR << endl;
655
669
return 1 ;
656
670
}
657
671
while (getline (scrsFile, comInFile)) {
@@ -669,7 +683,7 @@ int pulsStarterScript() {
669
683
fstream scrsFile;
670
684
scrsFile.open (current_path + " \\ accounts\\ " + CurrentPulsarInfo::account + " \\ startscript.puls" , fstream::in | fstream::out | ios::app);
671
685
if (!scrsFile.is_open ()) {
672
- cout << " Ошибка работы с файлом - " << current_path + " \\ accounts\\ " + CurrentPulsarInfo::account + " \\ startscript.puls" << endl;
686
+ cout << RED << " Ошибка работы с файлом - " << current_path + " \\ accounts\\ " + CurrentPulsarInfo::account + " \\ startscript.puls" << CLEAR << endl;
673
687
return 1 ;
674
688
}
675
689
while (getline (scrsFile, comInFile)) {
0 commit comments