Skip to content

Commit 7341638

Browse files
committed
2 parents 1fb01e0 + bf5e830 commit 7341638

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

cli/main.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,30 @@
1111

1212
using namespace std;
1313

14+
// https://stackoverflow.com/a/5867387
15+
std::string getEnvVar(std::string const& key)
16+
{
17+
char const* val = getenv(key.c_str());
18+
return val == NULL ? std::string() : std::string(val);
19+
}
20+
1421
int main(int argc, char** args)
1522
{
1623
init_networking();
1724

1825
setUserAgent("get-cli/" APP_VERSION);
1926

27+
// our config dir is in our current directory
28+
std::string config_dir = "./.get/";
29+
30+
// or use the home dir if it's defined
31+
std::string homeDir = getEnvVar("HOME");
32+
if (homeDir != "") {
33+
config_dir = homeDir + "/.config/libget-cli/";
34+
}
35+
2036
// create main Get object
21-
Get get("./.get/", "https://switch.cdn.fortheusers.org");
37+
Get get(config_dir, "https://switch.cdn.fortheusers.org");
2238

2339
auto repos = get.getRepos();
2440
auto packages = get.getPackages();

src/Get.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <optional>
66
#include <vector>
77
#include <unordered_set>
8+
#include <unordered_map>
89

910
void info(const char* format, ...);
1011

0 commit comments

Comments
 (0)