Compare commits

..

No commits in common. "2ed4323f9a7b0d2ce8136abdc34a2c1719eb639e" and "d83884b379270fdd24f8ae51c731cd72acab5533" have entirely different histories.

3 changed files with 3 additions and 38 deletions

1
.gitignore vendored
View file

@ -1,3 +1,2 @@
build/
.vscode/
goodideas.md

View file

@ -1,10 +0,0 @@
{ pkgs ? import <nixpkgs> {}}:
pkgs.mkShell {
packages = with pkgs; [
cmake
gnumake
ninja
tomlplusplus
cpptoml
];
}

View file

@ -1,9 +1,7 @@
#include <ios>
#include <iostream>
#include <filesystem>
#include <algorithm>
#include <cctype>
#include <limits>
#include <string>
#include <cstdio>
#include <cstdlib>
@ -12,22 +10,6 @@
#include <stdexcept>
#include <cpptoml.h>
void clearBuffer(){
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
inline void checkIfExtractionFailed(){
if (!std::cin){ // if previous extraction failed
if (std::cin.eof()){ // check if eof and if yes aborts the program
std::abort();
}
std::cin.clear(); //put std::cin back into normal mode
clearBuffer(); // remove bad input
}
}
const std::string USAGE = R"#(usage: RapidMenu [flags] [<command> [args]]
LISTING COMMANDS:
-c: To specify which config to use.
@ -189,11 +171,10 @@ int main(int argc, char* argv[]) {
} else {
while (!(std::filesystem::exists(bconfigfile) && std::filesystem::is_regular_file(bconfigfile))) {
std::cout << "Invalid config file: " << bconfigfile << ' ';
std::cout << "Invalid config file: " << bconfigfile;
std::cout << "Please enter a valid config: ";
std::cin >> bconfigfile;
checkIfExtractionFailed();
clearBuffer(); // clear extra input if entered
bconfig = bconfigfile.c_str();
}
@ -202,16 +183,13 @@ int main(int argc, char* argv[]) {
// executable
std::cout << "What do you want to call your executable?: ";
std::cin >> bexeout;
checkIfExtractionFailed();
clearBuffer();
std::string bexefile = std::string(userHome) + "/.local/bin/" + bexeout;
if (std::filesystem::exists(bexefile) && std::filesystem::is_regular_file(bexefile)) {
while (std::filesystem::exists(bexefile) && std::filesystem::is_regular_file(bexefile)) {
std::cout << "do you want to overwrite: " << bexeout << "? (y/n) ";
std::cin >> byn;
checkIfExtractionFailed();
clearBuffer();
transform(byn.begin(), byn.end(), byn.begin(), ::tolower);
if (byn == "y") {
@ -220,8 +198,6 @@ int main(int argc, char* argv[]) {
} else if (byn == "n") {
std::cout << "What do you want to call your executable?: ";
std::cin >> bexeout;
checkIfExtractionFailed();
clearBuffer();
bexe = bexeout.c_str();
}
}