cellar is now capable of finding your steam libraries

This commit is contained in:
Nicole O'Connor 2025-01-20 16:31:48 -08:00
parent ce8c26e58c
commit 0f679dc345
7 changed files with 50 additions and 11 deletions

View File

@ -53,7 +53,7 @@ set(src "${CMAKE_SOURCE_DIR}/src")
set(libcellar_subdirs bottles config launch paths)
if(ENABLE_STEAM)
list(APPEND steam)
list(APPEND libcellar_subdirs steam)
endif()
build_library(TARGET libcellar
SUBDIRS ${libcellar_subdirs}

View File

@ -1,10 +0,0 @@
#pragma once
#include <string>
#include <vector>
namespace cellar {
namespace steam {
extern std::vector<std::string> find_steam_libraries();
}
}

View File

@ -0,0 +1,26 @@
#pragma once
#include <map>
#include <string>
#include <vector>
#include "commands.hpp"
namespace cellar {
namespace steam {
extern std::vector<std::string> find_steam_libraries();
extern void test_command(int argc, std::vector<std::string> argv);
/*[[[cog
import cog
with open("src/steam/commands.txt") as commandsfile:
for line in commandsfile:
item = line.strip().split(" ")
cog.outl("extern void {0} (int, vector<string>);".format(item[1]))
]]]*/
//[[[end]]]
}
namespace commands {
extern std::map<std::string,cellar::commands::CommandFunction> steam_commands();
}
}

View File

@ -2,3 +2,4 @@ core
config
bottles
launch
steam

1
src/steam/commands.txt Normal file
View File

@ -0,0 +1 @@
steamtest test_command Test Steam related thing.

View File

@ -20,4 +20,14 @@ std::vector<std::string> cellar::steam::find_steam_libraries() {
std::ifstream fd_steam_library_config(str_steam_library_config);
auto hnd_steam_library_config = vdf::read(fd_steam_library_config);
std::vector<std::string> result;
for (auto hnd_library_def : hnd_steam_library_config.childs) {
std::string str_index = hnd_library_def.first;
auto hnd_library = hnd_library_def.second;
result.push_back(hnd_library->attribs["path"]);
}
return result;
}

View File

@ -0,0 +1,11 @@
#include <iostream>
#include "output.hpp"
#include "steam.hpp"
#include "internal/steam.hpp"
void cellar::steam::test_command(int argc, std::vector<std::string> argv) {
for (std::string str_path : cellar::steam::find_steam_libraries()) {
output::statement(str_path);
}
}