summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudius "keldu" Holeksa <mail@keldu.de>2025-10-16 11:56:19 +0200
committerClaudius "keldu" Holeksa <mail@keldu.de>2025-10-16 11:56:19 +0200
commit2c850f934d7087061e6f8540ee3a273b9817fbc7 (patch)
tree7567acbba4991e651f468a8ebc655d5720e34f21
parentb644689e018f5139c2c7d8d782f086120d07dd18 (diff)
Some changes in todomain
-rw-r--r--run_and_record/c++/main.cpp52
-rw-r--r--run_and_record/todo.txt8
2 files changed, 59 insertions, 1 deletions
diff --git a/run_and_record/c++/main.cpp b/run_and_record/c++/main.cpp
index 81ca570..9a33f59 100644
--- a/run_and_record/c++/main.cpp
+++ b/run_and_record/c++/main.cpp
@@ -25,6 +25,18 @@ using RarArgs = Args<
}
/**
+ * Check if HOME env variable is set and where it points to.
+ */
+saw::error_or<std::filesystem::path> get_home_env(){
+ const char* home = std::getenv("HOME");
+ if(not home){
+ return saw::make_error<saw::err::not_found>("HOME env variable not set");
+ }
+
+ return {home};
+}
+
+/**
* Run program by fork + exec
* Arguments are the program path + following args
*/
@@ -78,9 +90,47 @@ saw::error_or<void> kel_main(int argc, char** argv){
// args til 1
// Run program with argc - (sep_pos+1) = 1 arg_count => argc_prog = 1 starting at sep_pos+1
- // 0 til i/sep_pos-1 with count of sep_pos
+
+ // Grab home variable Check the default config location and try to decode the file
saw::data<sch::RarArgs> args;
{
+ auto eo_home = get_home_env();
+ if(eo_home.is_error()){
+ return std::move(eov.get_error());
+ }
+ auto& home = eov.get_value();
+
+ auto conf_file = home / ".config" / "kel" / "run_and_record.json";
+
+ saw::remote<saw::rmt::File> file_remote;
+ auto eo_addr = file_remote.parse_address(conf_file);
+ if(eo_addr.is_error()){
+ return std::move(eo_addr.get_error());
+ }
+ auto& addr = eo_addr.get_value();
+ auto eo_srv = file_remote.template data_listen<sch::RarConfig,saw::encode::Json>({*addr});
+ if(eo_srv.is_error()){
+ return std::move(eo_srv.get_error());
+ }
+ auto& srv = eo_srv.get_value();
+ saw::id<sch::RarConfig> fid{0u};
+
+ auto eo_data = srv->receive({fid});
+ if(eo_data.is_error()){
+ return std::move(eo_data.get_error());
+ }
+ auto& data = eo_data.get_value();
+
+ saw::codec<sch::RarConfig, saw::encode::Json> json_cdc;
+ auto& args_str = args.template get<"arguments">();
+ auto eo_dec = json_cdc.decode(data,args_str);
+ if(eo_dec.is_error()){
+ return eo_dec;
+ }
+ }
+
+ // 0 til i/sep_pos-1 with count of sep_pos
+ {
saw::data<sch::RarArgs, saw::encode::Args> enc_args{sep_pos,argv};
saw::codec<sch::RarArgs, saw::encode::Args> args_codec;
diff --git a/run_and_record/todo.txt b/run_and_record/todo.txt
index 7c796fc..1817c2e 100644
--- a/run_and_record/todo.txt
+++ b/run_and_record/todo.txt
@@ -1 +1,9 @@
* Actually test things
+* read config.json from ~/.config/kel/run_and_record/config.json
+* Create folder based on time and random id or maybe hash content?
+ - Record env
+ - Record git hash if exists
+ - Record command used
+ - Record additional files used
+* Possibly record crash?
+* Maybe record std::cout?