From 750f35bc363f4c14e1b186a2df4810bcf9b4217e Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Mon, 11 Mar 2024 17:15:18 -0600 Subject: [PATCH] add `--include-private` to db dump rpc --- core/startos/src/db/mod.rs | 34 ++++++++++++++++++++++++++-------- patch-db | 2 +- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/core/startos/src/db/mod.rs b/core/startos/src/db/mod.rs index bf09c0ff2..bfb8435e2 100644 --- a/core/startos/src/db/mod.rs +++ b/core/startos/src/db/mod.rs @@ -182,8 +182,18 @@ pub enum RevisionsRes { Dump(Dump), } +#[derive(Deserialize, Serialize, Parser)] +#[serde(rename_all = "kebab-case")] +#[command(rename_all = "kebab-case")] +pub struct CliDumpParams { + path: Option, +} + #[instrument(skip_all)] -async fn cli_dump(ctx: CliContext, DumpParams { path }: DumpParams) -> Result { +async fn cli_dump( + ctx: CliContext, + CliDumpParams { path }: CliDumpParams, +) -> Result { let dump = if let Some(path) = path { PatchDb::open(path).await?.dump(&ROOT).await } else { @@ -197,15 +207,23 @@ async fn cli_dump(ctx: CliContext, DumpParams { path }: DumpParams) -> Result, + #[arg(long = "include-private", short = 'p')] + #[serde(default)] + include_private: bool, } -// #[command( -// custom_cli(cli_dump(async, context(CliContext))), -// display(display_serializable) -// )] -pub async fn dump(ctx: RpcContext, _: DumpParams) -> Result { - Ok(ctx.db.dump(&*PUBLIC).await) +pub async fn dump( + ctx: RpcContext, + DumpParams { include_private }: DumpParams, +) -> Result { + Ok(ctx + .db + .dump(&if include_private { + ROOT + } else { + PUBLIC.borrowed() + }) + .await) } #[instrument(skip_all)] diff --git a/patch-db b/patch-db index 899c63afb..3dc11afd4 160000 --- a/patch-db +++ b/patch-db @@ -1 +1 @@ -Subproject commit 899c63afb5367c66bca6cafb98164d8cbd78f7e3 +Subproject commit 3dc11afd46d93094ac52ae1fef311a91c4561e8c