Skip to content

Commit

Permalink
Added feature to change to package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Engler committed Oct 6, 2018
1 parent 9c55a89 commit fd963ed
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ int main(int argc, char *argv[]) {
//If read_conf detects something invalid, the return will be ERROR
if(pm == "ERROR") {
cout << "Broken config" << endl;
system("rm /usr/local/share/sysget/config.txt");
exit(1);
if(remove("/usr/local/share/sysget/config.txt") != 0) {
cout << "Error while deleting broken config file, are you root ?" << endl;
exit(1);
}

else {
exit(1);
}
}

//If user enters no operation
Expand Down Expand Up @@ -118,6 +124,24 @@ int main(int argc, char *argv[]) {
clean(pm);
}

else if(string(argv[1]) == "set") {
if(argc < 3) {
cout << "Error, no package manager provided" << endl;
exit(1);
}

if(remove("/usr/local/share/sysget/config.txt") != 0) {
cout << "Error while deleting the config file, are you root ?" << endl;
exit(1);
}

else {
create_conf("/usr/local/share/sysget/config.txt", string(argv[2]) + "\n");
cout << "Package manager changed to " << string(argv[2]) << endl;
}

}

//Help
else if(string(argv[1]) == "help") {
cout << "Help of sysget" << endl;
Expand All @@ -131,6 +155,7 @@ int main(int argc, char *argv[]) {
cout << "upgrade\t\t\tdo a system upgrade" << endl;
cout << "upgrade [package]\tupgrade a specific package" << endl;
cout << "clean\t\t\tclean the download cache" << endl;
cout << "set [NEW MANAGER]\tset a new package manager" << endl;
cout << endl;
}

Expand Down

0 comments on commit fd963ed

Please sign in to comment.