gebs_cmd_run_collect() for collecting command output, Add examples/commands.c
This commit is contained in:
26
example/commands.c
Normal file
26
example/commands.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#define GEBS_IMPLEMENTATION
|
||||
#include "../gebs.h"
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
gebs_rebuild_self(argc, argv, "cc", "-o", "commands", __FILE__);
|
||||
|
||||
int code = GEBS_CMD("ls", "-la");
|
||||
GEBS_LOGI("Exited with %d\n", code);
|
||||
|
||||
Gebs_Cmd cmd = {0};
|
||||
defer { gebs_list_free(&cmd); }
|
||||
gebs_cmd_append(&cmd, "ls");
|
||||
gebs_cmd_append(&cmd, "-la");
|
||||
|
||||
|
||||
Gebs_String_Builder out_sb = {0};
|
||||
defer { gebs_sb_free(&out_sb); }
|
||||
code = gebs_cmd_run_collect(&cmd, &out_sb);
|
||||
printf("CAPTURED\n%sCAPTURED\n", out_sb.items);
|
||||
|
||||
GEBS_LOGI("Exited with %d\n", code);
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user