@ -7,6 +7,7 @@
# include "format.h"
# include <stdio.h>
# include <stdlib.h>
# include <stdbool.h>
# include <string.h>
@ -20,6 +21,7 @@ struct cli_request
static int cli_route_command ( struct cli_request * req , const char * cmd , int count , const char * usage_args )
{
if ( 0 ! = strcmp ( req - > argv [ 0 ] , cmd ) ) {
printf ( " No match for %s==%s \n " , req - > argv [ 0 ] , cmd ) ;
return 0 ;
}
req - > argv + = 1 ;
@ -159,6 +161,41 @@ static bool handle_command_test( struct cli_request* req )
account_free ( owner_account ) ;
}
bool handle_command_account_sync ( struct cli_request * req , struct account * a )
{
printf ( " sync cmd = %s \n " , req - > argv [ 0 ] ) ;
int res = cli_route_command ( req , " sync " , 0 , " " ) ;
if ( res ! = 1 ) { return ! ! res ; }
printf ( " Syncing account %d (%s) \n " , a - > id , a - > account_url ) ;
account_sync_from_activity_pub ( a - > id ) ;
return true ;
}
bool handle_command_account ( struct cli_request * req )
{
printf ( " cmd = %s \n " , req - > argv [ 0 ] ) ;
int res = cli_route_command ( req , " account " , 1 , " account (id) " ) ;
if ( res ! = 1 ) { return ! ! res ; }
bool result = false ;
struct account * a = account_from_id ( atoi ( req - > argv [ 0 ] ) ) ;
req - > argv + = 1 ;
req - > argc - = 1 ;
if ( handle_command_account_sync ( req , a ) ) { goto done ; }
result = false ;
cleanup :
account_free ( a ) ;
return result ;
done :
result = true ;
goto cleanup ;
}
void handle_command ( char * * argv , int argc )
{
struct cli_request req = {
@ -167,12 +204,15 @@ void handle_command( char** argv, int argc )
. binary_name = argv [ 0 ]
} ;
false
if ( false
| | handle_command_follow ( & req )
| | handle_command_unfollow ( & req )
| | handle_command_activity ( & req )
| | handle_command_status ( & req )
| | handle_command_account ( & req )
| | handle_command_reindex ( & req )
| | handle_command_test ( & req )
;
) { return ; }
printf ( " Unknown command %s \n " , argv [ 1 ] ) ;
}