Skip to content

Commit adf3e8a

Browse files
feat: Adds help output for every flag. It's kind of useless, since each flag should be self explanatory and shown in the main help output.
1 parent 21e5b66 commit adf3e8a

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

main.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,10 @@ std::vector<std::string> normalizeArgs(std::vector<std::string>& args) {
20892089
return args;
20902090
}
20912091

2092-
2092+
bool contains(const std::vector<std::string>& v, const std::string& value) {
2093+
return std::find(v.begin(), v.end(), value) != v.end();
2094+
}
2095+
// contains function that checks if the stringy vector contains the thing its self explanatory
20932096

20942097
int main(int argc, char* argv[]) {
20952098
SetConsoleOutputCP(CP_UTF8);
@@ -2150,13 +2153,21 @@ int main(int argc, char* argv[]) {
21502153
return 0; // exit after printing help because it might try to process -help as a process name otherwise
21512154
}
21522155

2153-
2156+
// at this point, if help exists but is not the first argument we can assume the user is asking about a specific flag
2157+
bool help = contains(args, "-help");
2158+
21542159
if (args[1] == "-v" || args[1] == "-version") {
2160+
if (!help) {
21552161
std::cout << "\nwin-witr " << version << std::endl;
2162+
} else {
2163+
std::cout << "Shows the version number of win-witr. If it says \"dev-build\", it means you compiled it yourself without a version number compiler environment variable.\n";
2164+
2165+
}
21562166
return 0;
21572167
}
21582168

21592169
if (args[1] == "-pid") {
2170+
if (!help) {
21602171
if (i + 1 < args.size()) {
21612172

21622173
std::string pidStr = args[i + 1]; // never increment the actual variable unless you're actually trying to find the next argument, otherwise
@@ -2213,9 +2224,14 @@ int main(int argc, char* argv[]) {
22132224
return 1;
22142225
}
22152226
return 0;
2216-
}
2227+
}
2228+
else {
2229+
std::cout << "Looks up a specific process based on the Process ID (PID) and returns information such as RAM usage, process ancestry, listening ports, and more.\n";
2230+
2231+
}}
22172232
// check for process name if no recognized flags
22182233
else {
2234+
if (!help) {
22192235
std::string procName = args[1];
22202236
HANDLE hshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
22212237
if (INVALID_HANDLE_VALUE == hshot) {return 1;}
@@ -2232,6 +2248,10 @@ int main(int argc, char* argv[]) {
22322248
}
22332249
}
22342250
}
2251+
} else {
2252+
std::cout << "Looks up a process based on the name. The search is case-insensitive, and you do not need to type the .exe extension. If there are multiple processes with similar names, it will show them to you under \"Related Processes\" along with their PIDs so you can manually search up each one using the --pid flag.
2253+
2254+
}
22352255
}
22362256
return 0;
22372257

0 commit comments

Comments
 (0)