test: More CLI tests, and make -u optional for publish, too.

This commit is contained in:
2025-05-07 18:31:58 -04:00
parent 4de53b9926
commit 86ef74e20d
2 changed files with 61 additions and 7 deletions

View File

@ -461,7 +461,7 @@ static int _tf_command_publish(const char* file, int argc, char* argv[])
}
}
if (show_usage || !user || !identity || !content)
if (show_usage || !identity || !content)
{
tf_printf("\n%s publish [options]\n\n", file);
tf_printf("options:\n");
@ -480,6 +480,14 @@ static int _tf_command_publish(const char* file, int argc, char* argv[])
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, db_path, NULL);
tf_ssb_set_quiet(ssb, true);
uint8_t private_key[512] = { 0 };
bool free_user = false;
if (!user)
{
user = tf_ssb_db_get_user_for_identity(ssb, identity);
free_user = true;
}
if (tf_ssb_db_identity_get_private_key(ssb, user, identity, private_key, sizeof(private_key)))
{
JSContext* context = tf_ssb_get_context(ssb);
@ -509,6 +517,12 @@ static int _tf_command_publish(const char* file, int argc, char* argv[])
{
tf_printf("Did not find private key for identity %s belonging to %s.\n", identity, user);
}
if (free_user)
{
tf_free((void*)user);
}
tf_ssb_destroy(ssb);
tf_free((void*)default_db_path);
return result;