summaryrefslogtreecommitdiff
path: root/src/app_console/app_console.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/app_console/app_console.cpp')
-rw-r--r--src/app_console/app_console.cpp87
1 files changed, 2 insertions, 85 deletions
diff --git a/src/app_console/app_console.cpp b/src/app_console/app_console.cpp
index 4a57853c..7f576a01 100644
--- a/src/app_console/app_console.cpp
+++ b/src/app_console/app_console.cpp
@@ -123,7 +123,8 @@ int CmdPlayFile(int argc, char** argv) {
if (is_id) {
database::TrackId id = std::atoi(argv[1]);
- AppConsole::sServices->track_queue().AddLast(id);
+ auto editor = AppConsole::sServices->track_queue().Edit();
+ AppConsole::sServices->track_queue().Append(editor, id);
} else {
std::pmr::string path{&memory::kSpiRamResource};
path += '/';
@@ -214,89 +215,6 @@ void RegisterDbTracks() {
esp_console_cmd_register(&cmd);
}
-int CmdDbIndex(int argc, char** argv) {
- std::cout << std::endl;
- vTaskDelay(1);
- static const std::pmr::string usage = "usage: db_index [id] [choices ...]";
-
- auto db = AppConsole::sServices->database().lock();
- if (!db) {
- std::cout << "no database open" << std::endl;
- return 1;
- }
-
- auto indexes = db->GetIndexes();
- if (argc <= 1) {
- std::cout << usage << std::endl;
- std::cout << "available indexes:" << std::endl;
- std::cout << "id\tname" << std::endl;
- for (const database::IndexInfo& info : indexes) {
- std::cout << static_cast<int>(info.id) << '\t' << info.name << std::endl;
- }
- return 0;
- }
-
- int index_id = std::atoi(argv[1]);
- auto index = std::find_if(indexes.begin(), indexes.end(),
- [=](const auto& i) { return i.id == index_id; });
- if (index == indexes.end()) {
- std::cout << "bad index id" << std::endl;
- return -1;
- }
-
- std::shared_ptr<database::Result<database::IndexRecord>> res(
- db->GetTracksByIndex(index->id, 20).get());
- int choice_index = 2;
-
- if (res->values().empty()) {
- std::cout << "no entries for this index" << std::endl;
- return 1;
- }
-
- while (choice_index < argc) {
- int choice = std::atoi(argv[choice_index]);
- if (choice >= res->values().size()) {
- std::cout << "choice out of range" << std::endl;
- return -1;
- }
- if (res->values().at(choice)->track()) {
- AppConsole::sServices->track_queue().IncludeLast(
- std::make_shared<playlist::IndexRecordSource>(
- AppConsole::sServices->database(), res, 0, res, choice));
- }
- auto cont = res->values().at(choice)->Expand(20);
- if (!cont) {
- std::cout << "more choices than levels" << std::endl;
- return 0;
- }
- res.reset(db->GetPage<database::IndexRecord>(&*cont).get());
- choice_index++;
- }
-
- for (const auto& r : res->values()) {
- std::cout << r->text().value_or("<unknown>");
- if (r->track()) {
- std::cout << "\t(id:" << *r->track() << ")";
- }
- std::cout << std::endl;
- }
-
- if (res->next_page()) {
- std::cout << "(more results not shown)" << std::endl;
- }
-
- return 0;
-}
-
-void RegisterDbIndex() {
- esp_console_cmd_t cmd{.command = "db_index",
- .help = "queries the database by index",
- .hint = NULL,
- .func = &CmdDbIndex,
- .argtable = NULL};
- esp_console_cmd_register(&cmd);
-}
-
int CmdDbDump(int argc, char** argv) {
static const std::pmr::string usage = "usage: db_dump";
if (argc != 1) {
@@ -726,7 +644,6 @@ auto AppConsole::RegisterExtraComponents() -> void {
*/
RegisterDbInit();
RegisterDbTracks();
- RegisterDbIndex();
RegisterDbDump();
RegisterTasks();