add cron basics

This commit is contained in:
lp19 2025-01-23 09:16:13 +01:00
parent 6691b5a5b3
commit 67992355b4
6 changed files with 31 additions and 5 deletions

@ -1 +1 @@
Subproject commit 3780b41dd070436f3f55327b0a88f27a52e2dfa8
Subproject commit 960b763ecd144f156d05ec61f577b04107290137

View File

@ -3,12 +3,22 @@ CFLAGS = -std=c++17 -Wall -static -static-libgcc -static-libstdc++
SRCDIR = ./src
BINDIR = ./bin
$(BINDIR)/autom: $(SRCDIR)/main.cpp $(SRCDIR)/command.cpp $(SRCDIR)/inputparser.cpp $(SRCDIR)/settings.cpp
$(CC) $(CFLAGS) $^ -o $@
.PHONY: clean
.PHONY: clean generate build
all: generate build
generate:
mkdir -p $(BINDIR)
clean:
rm -f $(BINDIR)/autom
build: $(BINDIR)/autom
$(BINDIR)/autom: $(SRCDIR)/main.cpp $(SRCDIR)/command.cpp $(SRCDIR)/inputparser.cpp $(SRCDIR)/settings.cpp
$(CC) $(CFLAGS) $^ -o $@
install:
cp $(BINDIR)/autom /usr/local/bin/autom

View File

@ -1,4 +1,7 @@
#include "command.h"
#include <map>
#include <string>
#include <functional>
Command::Command() {}

View File

@ -27,6 +27,7 @@ void input(int argc, char *argv[])
command.addCommand("remove", "[script] - Remove a script", removeScript);
command.addCommand("show", "[script] - Shows a script", showScript);
command.addCommand("config", "<command> - Configures autom", config);
command.addCommand("cron", "<command> - Executes cron jobs", cron);
command.addCommand("logo", "- Shows the autom logo", logo);
command.addDefaultCommand(runScript);
@ -604,6 +605,14 @@ void removeScript(int argc, char *argv[])
}
}
void cron(int argc, char *argv[])
{
std::string cron_file = settings.value["cron_file"];
Cron cron();
cron.run();
}
// help function for showing help message
void help(int argc, char *argv[])
{

View File

@ -48,6 +48,8 @@ void editScript_fn(std::string name, std::string dir);
void removeScript(int argc, char *argv[]);
// show a script in the autom directory
void showScript(int argc, char *argv[]);
// cron function for executing cron jobs
void cron(int argc, char *argv[]);
// help function for showing help message
void help(int argc, char *argv[]);

View File

@ -70,7 +70,9 @@ public:
{"editor", editor},
{"search_dirs", {home}},
{"temp_dir", home + "/temp"},
{"autom_home_dir", home}};
{"autom_home_dir", home},
{"cron_file", home + "/cron.txt"},
{"scripts", {}}};
file << j.dump(4);