Pull upstream changes from TELY UI

This commit is contained in:
doylet committed 2026-11-26 15:10:16 +11:00
1 parent 7147ad52a2
commit d5c98d5288
20 files changed
+17900 -10682

No files matched your search

+26 -26
View File
@@ -16,24 +16,20 @@ DN_Str8 DN_SH_CLIOptionsStr8()
return result;
}
DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, char const **arg_ptr, int arg_count)
DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, DN_ArgvIterator *it)
{
DN_SHCLIEatArgResult result = {};
result.arg_ptr = arg_ptr;
result.arg_count = arg_count;
DN_Str8 arg = {};
if (arg_count)
arg = DN_Str8FromCStr8(*result.arg_ptr);
DN_Str8 arg = it->arg;
// NOTE: Try handling the argument if we recognise it
{
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-exe-path"))) {
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
result.eaten = true;
args->exe_path = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
DN_Str8 value = DN_ArgvPeek(it, 1);
DN_ArgvEat(it, 1);
result.eaten = true;
args->exe_path = value;
if (DN_OS_PathInfo(args->exe_path).type != DN_OSPathInfoType_File) {
if (DN_Os_PathInfo(args->exe_path).type != DN_OsPathInfoType_File) {
result.error_msg = DN_Str8Lit("Seshc executable path does not point to a file");
result.error_arg = args->exe_path;
args->exe_path = {};
@@ -41,27 +37,31 @@ DN_SHCLIEatArgResult DN_SH_CLIEatArg(DN_SHCLIArgs *args, char const **arg_ptr, i
}
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-account-secret"))) {
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
result.eaten = true;
args->account_secret = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
DN_Str8 value = DN_ArgvPeek(it, 1);
DN_ArgvEat(it, 1);
result.eaten = true;
args->account_secret = value;
}
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-seed-node"))) {
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
result.eaten = true;
args->seed_node_url = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
DN_Str8 value = DN_ArgvPeek(it, 1);
DN_ArgvEat(it, 1);
result.eaten = true;
args->seed_node_url = value;
}
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-display-name"))) {
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
result.eaten = true;
args->display_name = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
DN_Str8 value = DN_ArgvPeek(it, 1);
DN_ArgvEat(it, 1);
result.eaten = true;
args->display_name = value;
}
if (!result.eaten && DN_Str8EqInsensitive(arg, DN_Str8Lit("--seshc-recipient-pkey"))) {
(void)DN_ArgShift(result.arg_ptr, result.arg_count);
result.eaten = true;
args->recipient_pkey = DN_Str8FromCStr8(DN_ArgShift(result.arg_ptr, result.arg_count));
DN_Str8 value = DN_ArgvPeek(it, 1);
DN_ArgvEat(it, 1);
result.eaten = true;
args->recipient_pkey = value;
DN_Str8 check = DN_Str8TrimHexPrefix(args->recipient_pkey);
if (!DN_Str8StartsWithSensitive(check, DN_Str8Lit("05"))) {
@@ -103,9 +103,9 @@ bool DN_SH_CLIArgsSendDMFmt(DN_SHCLIArgs *cli_args, DN_Str8 sesh_pkey_hex, char
cmd_line.data = cmds;
cmd_line.count = DN_ArrayCountU(cmds);
DN_OSExecArgs exec_args = {};
exec_args.flags |= DN_OSExecFlags_SaveOutput;
DN_OSExecResult exec = DN_OS_Exec(cmd_line, &exec_args, &scratch.arena, nullptr);
DN_OsExecArgs exec_args = {};
exec_args.flags |= DN_OsExecFlags_SaveOutput;
DN_OsExecResult exec = DN_Os_Exec(cmd_line, &exec_args, &scratch.arena, nullptr);
DN_LogInfoF("OUT (exit code:%zu, os: %zu): %.*s", exec.exit_code, exec.os_error_code, DN_Str8PrintFmt(exec.stdout_text));
DN_LogInfoF("ERR: %.*s", DN_Str8PrintFmt(exec.stderr_text));
DN_TCScratchEnd(&scratch);
+1 -3
View File
@@ -21,8 +21,6 @@ struct DN_SHCLIEatArgResult
bool eaten;
DN_Str8 error_msg; // Parsing error message. String is immutably stored in the data-segment w/ program lifetime.
DN_Str8 error_arg; // Argument that caused the parsing error
char const **arg_ptr; // Next argument pointer that that the caller should proceed from
DN_USize arg_count; // Next argument count that that the caller should assume
};
// NOTE: Seshc
@@ -30,7 +28,7 @@ struct DN_SHCLIEatArgResult
// Helper library that provides some useful APIs for programatically calling the Seshc CLI
// executable to send messages from your C/C++ application.
DN_Str8 DN_SH_CLIOptionsStr8 ();
DN_SHCLIEatArgResult DN_SH_CLIEatArg (DN_SHCLIArgs *args, char const **arg_ptr, int arg_count);
DN_SHCLIEatArgResult DN_SH_CLIEatArg (DN_SHCLIArgs *args, DN_ArgvIterator *it);
bool DN_SH_CLIArgsSendDMFmt(DN_SHCLIArgs *cli_args, DN_Str8 sesh_pkey_hex, char const *fmt, ...);
#endif // #if !defined(DN_SESHC_H)