mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
merge all "show" commands into a single command
This commit is contained in:
@@ -76,54 +76,49 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
|
||||
//
|
||||
// Show commands
|
||||
//
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, {F_(show)}, [=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
commands->add_command(
|
||||
ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
{F_(show)},
|
||||
{F_(show_commands)},
|
||||
[=](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
if (arguments.empty()) {
|
||||
to_app(shell).system_.show_system(shell);
|
||||
});
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
string_vector{F_(show), F_(system)},
|
||||
[=](Shell & shell, const std::vector<std::string> & arguments) { to_app(shell).system_.show_system(shell); });
|
||||
return;
|
||||
}
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::ADMIN,
|
||||
string_vector{F_(show), F_(users)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) { to_app(shell).system_.show_users(shell); });
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
string_vector{F_(show), F_(devices)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) { to_app(shell).show_devices(shell); });
|
||||
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{F_(show), F_(log)}, [](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
auto command = arguments.front();
|
||||
if (command == F_(commands)) {
|
||||
Command::show_all(shell);
|
||||
} else if (command == F_(system)) {
|
||||
to_app(shell).system_.show_system(shell);
|
||||
} else if (command == F_(users) && (shell.has_flags(CommandFlags::ADMIN))) {
|
||||
to_app(shell).system_.show_users(shell); // admin only
|
||||
} else if (command == F_(devices)) {
|
||||
to_app(shell).show_devices(shell);
|
||||
} else if (command == F_(log)) {
|
||||
to_app(shell).webLogService.show(shell);
|
||||
});
|
||||
|
||||
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{F_(show), F_(ems)}, [](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
} else if (command == F_(ems)) {
|
||||
to_app(shell).show_ems(shell);
|
||||
});
|
||||
|
||||
commands->add_command(ShellContext::MAIN, CommandFlags::USER, string_vector{F_(show), F_(values)}, [](Shell & shell, const std::vector<std::string> & arguments) {
|
||||
} else if (command == F_(values)) {
|
||||
to_app(shell).show_device_values(shell);
|
||||
to_app(shell).show_sensor_values(shell);
|
||||
} else if (command == F_(mqtt)) {
|
||||
Mqtt::show_mqtt(shell);
|
||||
} else if (command == F_(commands)) {
|
||||
Command::show_all(shell);
|
||||
} else {
|
||||
shell.printfln("Unknown show command");
|
||||
}
|
||||
},
|
||||
[](Shell & shell, const std::vector<std::string> & current_arguments, const std::string & next_argument) -> std::vector<std::string> {
|
||||
return std::vector<std::string>{"system", "users", "devices", "log", "ems", "values", "mqtt", "commands"};
|
||||
});
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
string_vector{F_(show), F_(mqtt)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) { Mqtt::show_mqtt(shell); });
|
||||
|
||||
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
CommandFlags::USER,
|
||||
string_vector{F_(show), F_(commands)},
|
||||
[](Shell & shell, const std::vector<std::string> & arguments) { Command::show_all(shell); });
|
||||
|
||||
|
||||
//
|
||||
// System commands
|
||||
//
|
||||
|
||||
#if defined(EMSESP_TEST)
|
||||
// create commands test
|
||||
commands->add_command(ShellContext::MAIN,
|
||||
|
||||
@@ -154,6 +154,7 @@ MAKE_WORD_CUSTOM(deviceid_mandatory, "<deviceID>")
|
||||
MAKE_WORD_CUSTOM(device_type_optional, "[device]")
|
||||
MAKE_WORD_CUSTOM(invalid_log_level, "Invalid log level")
|
||||
MAKE_WORD_CUSTOM(log_level_optional, "[level]")
|
||||
MAKE_WORD_CUSTOM(show_commands, "[system | users | devices | log | ems | values | mqtt | commands")
|
||||
MAKE_WORD_CUSTOM(name_mandatory, "<name>")
|
||||
MAKE_WORD_CUSTOM(name_optional, "[name]")
|
||||
MAKE_WORD_CUSTOM(new_password_prompt1, "Enter new password: ")
|
||||
|
||||
@@ -63,7 +63,7 @@ MAKE_WORD_TRANSLATION(info_cmd, "list all values (verbose)", "Liste aller Werte"
|
||||
MAKE_WORD_TRANSLATION(commands_cmd, "list all commands", "Liste aller Kommandos", "lijst van alle commando's", "", "wyświetl wszystkie komendy", "Viser alle kommandoer", "", "Tüm komutları listele", "elencaa tutti i comandi", "zobraziť všetky príkazy") // TODO translate
|
||||
MAKE_WORD_TRANSLATION(entities_cmd, "list all entities", "Liste aller Entitäten", "lijst van alle entiteiten", "", "wyświetl wszsytkie encje", "Viser alle enheter", "", "Tüm varlıkları listele", "elenca tutte le entità", "zobraziť všetky entity") // TODO translate
|
||||
MAKE_WORD_TRANSLATION(send_cmd, "send a telegram", "Sende EMS-Telegramm", "stuur een telegram", "", "wyślij telegram", "send et telegram", "", "Bir telegram gönder", "invia un telegramma", "poslať telegram") // TODO translate
|
||||
MAKE_WORD_TRANSLATION(setiovalue_cmd, "set io value", "Setze Werte E/A", "instellen standaardwaarde", "", "ustaw wartość", "sett en io verdi", "", "Giriş/Çıkış değerlerini ayarla", "imposta valore io", "nastaviť hodnotu io") // TODO translate
|
||||
MAKE_WORD_TRANSLATION(setiovalue_cmd, "set I/O value", "Setze Werte E/A", "instellen standaardwaarde", "", "ustaw wartość", "sett en io verdi", "", "Giriş/Çıkış değerlerini ayarla", "imposta valore io", "nastaviť hodnotu io") // TODO translate
|
||||
MAKE_WORD_TRANSLATION(changeloglevel_cmd, "change log level", "Ändere Protokollebene", "aanpassen log niveau", "", "zmień poziom log-u", "endre loggnivå", "", "Kayıt seviyesini değiştir", "cambia livello registrazione", "zmeniť úroveň protokolu") // TODO translate
|
||||
MAKE_WORD_TRANSLATION(fetch_cmd, "refresh all EMS values", "Aktualisiere alle EMS-Werte", "Verversen alle EMS waardes", "", "odśwież wszystkie wartości EMS", "oppfrisk alle EMS verdier", "", "Bütün EMS değerlerini yenile", "aggiornare tutti i valori EMS", "obnoviť všetky hodnoty EMS") // TODO translate
|
||||
MAKE_WORD_TRANSLATION(restart_cmd, "restart EMS-ESP", "Neustart", "opnieuw opstarten", "", "uruchom ponownie EMS-ESP", "restart EMS-ESP", "redémarrer EMS-ESP", "EMS-ESPyi yeniden başlat", "riavvia EMS-ESP", "reštart EMS-ESP") // TODO translate
|
||||
|
||||
Reference in New Issue
Block a user