You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/starfetch.cpp
+8-13
Original file line number
Diff line number
Diff line change
@@ -16,10 +16,10 @@
16
16
usingnamespacestd;
17
17
using json = nlohmann::json;
18
18
19
-
staticvoidsetColor(constchar *str);
19
+
staticvoidsetColor(constchar *str);//sets given color to the REQUESTED_COLOR variable to colorize the output constellation
20
20
staticinlinevoidPrintConst(string &pathc); //formats the template file with the requested data and prints out the constellation info
21
21
static string RandomConst(); //select a random constellation from the available ones
22
-
staticinlinevoidPrintList(); //prints out the list of the available constellations
22
+
staticvoidPrintList(); //prints out the list of the available constellations
23
23
staticvoidError(constchar *err, int type); //shows an error message
24
24
staticvoidHelp(); //prints out the help message
25
25
@@ -44,20 +44,18 @@ int main(int argc, char *argv[])
44
44
case'n':
45
45
{
46
46
if(argc < 3) Error("", 0); //if the user requested a '-n' argument but didn't provide a name, an error occours
47
-
pathc += "constellations" + SEP; //updating the path to the constellations folder
48
-
pathc += argv[2]; //adding the name of the requested constellation to the path
49
-
pathc += ".json";
47
+
pathc += "constellations" + SEP + argv[2] + ".json"; //updating the path to the constellations folder and adding the name of the requested constallation to the pathc
50
48
}
51
49
break;
52
50
case'h':
53
51
Help();
54
-
break;
52
+
return EXIT_SUCCESS;
55
53
case'r':
56
54
pathc += RandomConst(); //with the '-r' option, it selects a random constellation
57
55
break;
58
56
case'l':
59
57
PrintList();
60
-
break;
58
+
return EXIT_SUCCESS;
61
59
case'c':
62
60
{
63
61
if (argc == 2)
@@ -79,9 +77,7 @@ int main(int argc, char *argv[])
79
77
}
80
78
else
81
79
{
82
-
pathc += "constellations" + SEP; //updating the path to the constellations folder
83
-
pathc += argv[4]; //adding the name of the requested constellation to the path
84
-
pathc += ".json";
80
+
pathc += "constellations" + SEP + argv[4] + ".json"; //updating the path to the constellations folder and adding the name of the requested constellation to the pathc
cout << REQUESTED_COLOR + "✦ available constellations\033[0;0m:" << endl;
206
202
//prints every constellation name from the files name in the "constellations/" directory
207
203
for (constauto & entry : filesystem::directory_iterator(path+"constellations" + SEP))
208
204
{
209
205
s = entry.path().u8string().substr(entry.path().u8string().find("constellations" + SEP)+15); //from "/usr/local/opt/starfetch/res/constellations/xxxxxx" to "xxxxxx"
0 commit comments