bump: 0.3 and updated c++
This commit is contained in:
parent
301d3b0a2d
commit
988b785193
4 changed files with 38 additions and 49 deletions
|
@ -1,4 +1,4 @@
|
||||||
cmake_minimum_required(VERSION 3.19)
|
cmake_minimum_required(VERSION 3.28.2)
|
||||||
|
|
||||||
# Get version
|
# Get version
|
||||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/props.json PROPS)
|
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/props.json PROPS)
|
||||||
|
@ -8,11 +8,20 @@ project(RapidMenu
|
||||||
DESCRIPTION "Utilize configuration files to create runner scripts."
|
DESCRIPTION "Utilize configuration files to create runner scripts."
|
||||||
VERSION ${VER})
|
VERSION ${VER})
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 23)
|
set(CMAKE_CXX_STANDARD 26)
|
||||||
|
|
||||||
|
# check if build type is set if it isnt set it to release
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(DCKMAKE_BUILD_TYPE Release)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Add the path to the source files for RapidMenu
|
# Add the path to the source files for RapidMenu
|
||||||
file(GLOB_RECURSE RAPID_MENU_SOURCE_FILES "src/*.cpp")
|
file(GLOB_RECURSE RAPID_MENU_SOURCE_FILES "src/*.cpp")
|
||||||
|
|
||||||
|
# add compiler flags
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-03")
|
||||||
|
|
||||||
# Add the executable target for RapidMenu
|
# Add the executable target for RapidMenu
|
||||||
add_executable(RapidMenu ${RAPID_MENU_SOURCE_FILES})
|
add_executable(RapidMenu ${RAPID_MENU_SOURCE_FILES})
|
||||||
install(TARGETS RapidMenu DESTINATION bin)
|
install(TARGETS RapidMenu DESTINATION bin)
|
||||||
|
@ -21,7 +30,6 @@ install(TARGETS RapidMenu DESTINATION bin)
|
||||||
find_package(tomlplusplus REQUIRED)
|
find_package(tomlplusplus REQUIRED)
|
||||||
target_link_libraries(RapidMenu PRIVATE tomlplusplus::tomlplusplus)
|
target_link_libraries(RapidMenu PRIVATE tomlplusplus::tomlplusplus)
|
||||||
|
|
||||||
|
|
||||||
# DEBIAN
|
# DEBIAN
|
||||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "DRAGONTOS")
|
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "DRAGONTOS")
|
||||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libcpptoml-dev")
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libcpptoml-dev")
|
||||||
|
|
2
PKGBUILD
2
PKGBUILD
|
@ -1,6 +1,6 @@
|
||||||
pkgname=RapidMenu-git
|
pkgname=RapidMenu-git
|
||||||
_gitname=RapidMenu
|
_gitname=RapidMenu
|
||||||
pkgver=0.2.4
|
pkgver=0.3
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Utilize configuration files to create runner scripts."
|
pkgdesc="Utilize configuration files to create runner scripts."
|
||||||
url="https://github.com/DRAGONTOS/RapidMenu"
|
url="https://github.com/DRAGONTOS/RapidMenu"
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
{
|
{
|
||||||
"version": "0.2.4"
|
"version": "0.3"
|
||||||
}
|
}
|
||||||
|
|
51
src/main.cpp
51
src/main.cpp
|
@ -22,8 +22,8 @@ inline void checkIfExtractionFailed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cin.clear(); // put std::cin back into normal mode
|
std::cin.clear(); // put std::cin back into normal mode
|
||||||
clearBuffer(); // remove bad input
|
|
||||||
}
|
}
|
||||||
|
clearBuffer(); // remove bad input
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string USAGE = R"#(usage: RapidMenu [flags] [<command> [args]]
|
const std::string USAGE = R"#(usage: RapidMenu [flags] [<command> [args]]
|
||||||
|
@ -41,8 +41,7 @@ struct Action {
|
||||||
std::string command;
|
std::string command;
|
||||||
|
|
||||||
Action(const std::string &nms = "", const std::string &desc = "",
|
Action(const std::string &nms = "", const std::string &desc = "",
|
||||||
const std::string &cmd = "")
|
const std::string &cmd = "") : names(nms), description(desc), command(cmd) {}
|
||||||
: names(nms), description(desc), command(cmd) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void from_toml(const cpptoml::table &t, Action &a) {
|
void from_toml(const cpptoml::table &t, Action &a) {
|
||||||
|
@ -72,8 +71,7 @@ int main(int argc, char **argv, char **envp) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::filesystem::exists(rapidMenuPath) &&
|
if (std::filesystem::exists(rapidMenuPath) && std::filesystem::is_directory(rapidMenuPath)) {
|
||||||
std::filesystem::is_directory(rapidMenuPath)) {
|
|
||||||
} else {
|
} else {
|
||||||
system(rapidcommand.c_str());
|
system(rapidcommand.c_str());
|
||||||
std::cerr << "Setting up the config directory: " << rapidMenuPath;
|
std::cerr << "Setting up the config directory: " << rapidMenuPath;
|
||||||
|
@ -129,18 +127,11 @@ int main(int argc, char **argv, char **envp) {
|
||||||
|
|
||||||
namesList = namesStream.str();
|
namesList = namesStream.str();
|
||||||
|
|
||||||
std::string rname = config->get_table("runner")
|
std::string rname = config->get_table("runner") ->get_as<std::string>("rname") .value_or("dashboard:");
|
||||||
->get_as<std::string>("rname")
|
std::string rtheme = config->get_table("runner") ->get_as<std::string>("rtheme") .value_or("");
|
||||||
.value_or("dashboard:");
|
std::string rcommand = config->get_table("runner") ->get_as<std::string>("rcommand") .value_or("rofi -dmenu -p");
|
||||||
std::string rtheme = config->get_table("runner")
|
|
||||||
->get_as<std::string>("rtheme")
|
|
||||||
.value_or("");
|
|
||||||
std::string rcommand = config->get_table("runner")
|
|
||||||
->get_as<std::string>("rcommand")
|
|
||||||
.value_or("rofi -dmenu -p");
|
|
||||||
|
|
||||||
std::string rofiCommand = "printf '" + namesList + "' | " + rcommand +
|
std::string rofiCommand = "printf '" + namesList + "' | " + rcommand + " '" + rname + " ' " + rtheme;
|
||||||
" '" + rname + " ' " + rtheme;
|
|
||||||
FILE *rofiProcess = popen(rofiCommand.c_str(), "r");
|
FILE *rofiProcess = popen(rofiCommand.c_str(), "r");
|
||||||
|
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
@ -150,9 +141,7 @@ int main(int argc, char **argv, char **envp) {
|
||||||
userChoice += buffer;
|
userChoice += buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
userChoice.erase(remove_if(userChoice.begin(), userChoice.end(),
|
userChoice.erase(remove_if(userChoice.begin(), userChoice.end(), [](char c) { return c == '\n'; }), userChoice.end());
|
||||||
[](char c) { return c == '\n'; }),
|
|
||||||
userChoice.end());
|
|
||||||
for (const auto &tableItem : *config) {
|
for (const auto &tableItem : *config) {
|
||||||
try {
|
try {
|
||||||
const auto &table = tableItem.second->as_table();
|
const auto &table = tableItem.second->as_table();
|
||||||
|
@ -195,8 +184,7 @@ int main(int argc, char **argv, char **envp) {
|
||||||
std::string bindir = std::string(userHome) + "/.local/bin";
|
std::string bindir = std::string(userHome) + "/.local/bin";
|
||||||
std::string createbindir = "mkdir -p " + bindir;
|
std::string createbindir = "mkdir -p " + bindir;
|
||||||
|
|
||||||
if (std::filesystem::exists(bindir) &&
|
if (std::filesystem::exists(bindir) && std::filesystem::is_directory(bindir)) {
|
||||||
std::filesystem::is_directory(bindir)) {
|
|
||||||
} else {
|
} else {
|
||||||
system(createbindir.c_str());
|
system(createbindir.c_str());
|
||||||
std::cerr << "Setting up bin dir.";
|
std::cerr << "Setting up bin dir.";
|
||||||
|
@ -205,13 +193,11 @@ int main(int argc, char **argv, char **envp) {
|
||||||
|
|
||||||
// config
|
// config
|
||||||
std::string bconfigfile = bconfigin;
|
std::string bconfigfile = bconfigin;
|
||||||
if (std::filesystem::exists(bconfigfile) &&
|
if (std::filesystem::exists(bconfigfile) && std::filesystem::is_regular_file(bconfigfile)) {
|
||||||
std::filesystem::is_regular_file(bconfigfile)) {
|
|
||||||
bconfig = argv[2];
|
bconfig = argv[2];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
while (!(std::filesystem::exists(bconfigfile) &&
|
while (!(std::filesystem::exists(bconfigfile) && std::filesystem::is_regular_file(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::cout << "Please enter a valid config: ";
|
||||||
std::cin >> bconfigfile;
|
std::cin >> bconfigfile;
|
||||||
|
@ -228,10 +214,8 @@ int main(int argc, char **argv, char **envp) {
|
||||||
clearBuffer();
|
clearBuffer();
|
||||||
std::string bexefile = std::string(userHome) + "/.local/bin/" + bexeout;
|
std::string bexefile = std::string(userHome) + "/.local/bin/" + bexeout;
|
||||||
|
|
||||||
if (std::filesystem::exists(bexefile) &&
|
if (std::filesystem::exists(bexefile) && std::filesystem::is_regular_file(bexefile)) {
|
||||||
std::filesystem::is_regular_file(bexefile)) {
|
while (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::cout << "do you want to overwrite: " << bexeout << "? (y/n) ";
|
||||||
std::cin >> byn;
|
std::cin >> byn;
|
||||||
checkIfExtractionFailed();
|
checkIfExtractionFailed();
|
||||||
|
@ -256,13 +240,10 @@ int main(int argc, char **argv, char **envp) {
|
||||||
|
|
||||||
system(("touch " + bexefile + std::string(bexe)).c_str());
|
system(("touch " + bexefile + std::string(bexe)).c_str());
|
||||||
system(("chmod +x " + bexefile + std::string(bexe)).c_str());
|
system(("chmod +x " + bexefile + std::string(bexe)).c_str());
|
||||||
system(("echo '#!/usr/bin/env bash' > " + bexefile + std::string(bexe))
|
system(("echo '#!/usr/bin/env bash' > " + bexefile + std::string(bexe)).c_str());
|
||||||
.c_str());
|
system(("echo 'RapidMenu -c " + std::string(bconfig) + "' >> " + std::string(bexe)).c_str());
|
||||||
system(("echo 'RapidMenu -c " + std::string(bconfig) + "' >> " +
|
|
||||||
std::string(bexe))
|
|
||||||
.c_str());
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
std::cerr << USAGE;
|
std::cerr << USAGE;
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Reference in a new issue