@@ -10,11 +10,11 @@ use futures::future::pending;
1010use rostra_client:: error:: { ConnectError , IdResolveError , IdSecretReadError , InitError , PostError } ;
1111use rostra_client:: multiclient:: MultiClient ;
1212use rostra_client:: Client ;
13- use rostra_client_db:: DbError ;
13+ use rostra_client_db:: { Database , DbError } ;
1414use rostra_core:: id:: RostraIdSecretKey ;
1515use rostra_p2p:: connection:: { Connection , PingRequest , PingResponse } ;
1616use rostra_p2p:: RpcError ;
17- use rostra_util_error:: FmtCompact as _;
17+ use rostra_util_error:: { BoxedError , FmtCompact as _} ;
1818use rostra_web_ui:: { Server , WebUiServerError } ;
1919use snafu:: { FromString , ResultExt , Snafu , Whatever } ;
2020use tokio:: time:: Instant ;
@@ -49,6 +49,8 @@ pub enum CliError {
4949 DataDir { source : io:: Error } ,
5050 #[ snafu( display( "Database error: {source}" ) ) ]
5151 Database { source : DbError } ,
52+ #[ snafu( display( "Miscellaneous error: {source}" ) ) ]
53+ Other { source : BoxedError } ,
5254}
5355
5456pub type CliResult < T > = std:: result:: Result < T , CliError > ;
@@ -157,6 +159,20 @@ async fn handle_cmd(opts: Opts) -> CliResult<serde_json::Value> {
157159
158160 serde_json:: to_value ( & resp) . expect ( "Can't fail" )
159161 }
162+ cli:: DevCmd :: DbDump {
163+ rostra_id : id,
164+ table,
165+ } => {
166+ let db_path = Database :: mk_db_path ( opts. global . data_dir ( ) , id)
167+ . await
168+ . context ( DataDirSnafu ) ?;
169+
170+ let db = Database :: open ( & db_path, id) . await . context ( DatabaseSnafu ) ?;
171+
172+ db. dump_table ( & table) . await . boxed ( ) . context ( OtherSnafu ) ?;
173+
174+ serde_json:: to_value ( serde_json:: Value :: Null ) . expect ( "Can't fail" )
175+ }
160176 } ,
161177 cli:: OptsCmd :: Serve { secret_file } => {
162178 let secret_id = if let Some ( secret_file) = secret_file {
0 commit comments