mirror of
https://github.com/lucaspalomodevelop/autom.git
synced 2026-03-12 23:27:21 +00:00
add pre_script
This commit is contained in:
parent
e6c3de3d7d
commit
fba623e343
13
src/main.cpp
13
src/main.cpp
@ -31,6 +31,7 @@ void input(int argc, char *argv[])
|
|||||||
command.addCommandAlias("remove", "r");
|
command.addCommandAlias("remove", "r");
|
||||||
command.addCommand("show", "[script] - Shows a script", showScript);
|
command.addCommand("show", "[script] - Shows a script", showScript);
|
||||||
command.addCommandAlias("show", "s");
|
command.addCommandAlias("show", "s");
|
||||||
|
|
||||||
command.addDefaultCommand(runScript);
|
command.addDefaultCommand(runScript);
|
||||||
command.runCommand(argv[1], argc, argv);
|
command.runCommand(argv[1], argc, argv);
|
||||||
}
|
}
|
||||||
@ -42,6 +43,8 @@ void runScript(int argc, char *argv[])
|
|||||||
std::map<int, std::string> dir_options;
|
std::map<int, std::string> dir_options;
|
||||||
std::string dir = home_dir;
|
std::string dir = home_dir;
|
||||||
|
|
||||||
|
auto script_settings = settings.value["scripts"][argv[1]];
|
||||||
|
|
||||||
for (auto search_dir : settings.value["search_dirs"])
|
for (auto search_dir : settings.value["search_dirs"])
|
||||||
{
|
{
|
||||||
if (std::filesystem::exists((std::string)search_dir + "/" + argv[1]))
|
if (std::filesystem::exists((std::string)search_dir + "/" + argv[1]))
|
||||||
@ -88,6 +91,16 @@ void runScript(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
std::string script = pre_script + dir + "/" + argv[1] + " " + args;
|
std::string script = pre_script + dir + "/" + argv[1] + " " + args;
|
||||||
std::cout << "executing: " << (dir + "/" + argv[1] + " " + args) << std::endl;
|
std::cout << "executing: " << (dir + "/" + argv[1] + " " + args) << std::endl;
|
||||||
|
|
||||||
|
// if (script_settings["sudo"])
|
||||||
|
// script = "sudo " + script;
|
||||||
|
|
||||||
|
// if (script_settings["background"])
|
||||||
|
// script = script + " &";
|
||||||
|
|
||||||
|
if (script_settings["pre_script"].size() > 0)
|
||||||
|
system(script_settings["pre_script"].get<std::string>().c_str());
|
||||||
|
|
||||||
system(script.c_str());
|
system(script.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
#ifndef MAIN_H
|
#ifndef MAIN_H
|
||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -17,7 +16,7 @@
|
|||||||
Settings settings;
|
Settings settings;
|
||||||
// directory for autom scripts
|
// directory for autom scripts
|
||||||
std::string home_dir = "";
|
std::string home_dir = "";
|
||||||
Command command;
|
Command command;
|
||||||
|
|
||||||
// input function for parsing arguments and creating commands and running them
|
// input function for parsing arguments and creating commands and running them
|
||||||
void input(int argc, char *argv[]);
|
void input(int argc, char *argv[]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user