diff --git a/packages/cli-uwf/src/cli.ts b/packages/cli-uwf/src/cli.ts index 9002cc1..1f128ef 100755 --- a/packages/cli-uwf/src/cli.ts +++ b/packages/cli-uwf/src/cli.ts @@ -12,7 +12,6 @@ import { import { cmdWorkflowList, cmdWorkflowPut, cmdWorkflowShow } from "./commands/workflow.js"; import { cmdSetup, cmdSetupInteractive } from "./commands/setup.js"; import { - cmdCasCat, cmdCasGet, cmdCasHas, cmdCasPut, @@ -185,24 +184,13 @@ const cas = program.command("cas").description("Content-addressable storage oper cas .command("get") - .description("Read a CAS node as JSON") + .description("Read a CAS node (type + payload; use --timestamp to include timestamp)") .argument("", "CAS hash (13 char)") - .action((hash: string) => { + .option("--timestamp", "Include timestamp in output") + .action((hash: string, opts: { timestamp?: boolean }) => { const storageRoot = resolveStorageRoot(); runAction(async () => { - writeOutput(await cmdCasGet(storageRoot, hash)); - }); - }); - -cas - .command("cat") - .description("Output a CAS node (--payload for payload only)") - .argument("", "CAS hash (13 char)") - .option("--payload", "Output only the payload") - .action((hash: string, opts: { payload?: boolean }) => { - const storageRoot = resolveStorageRoot(); - runAction(async () => { - writeOutput(await cmdCasCat(storageRoot, hash, opts)); + writeOutput(await cmdCasGet(storageRoot, hash, opts)); }); }); diff --git a/packages/cli-uwf/src/commands/cas.ts b/packages/cli-uwf/src/commands/cas.ts index 934da7a..a580dc5 100644 --- a/packages/cli-uwf/src/commands/cas.ts +++ b/packages/cli-uwf/src/commands/cas.ts @@ -28,26 +28,18 @@ function readJsonArg(fileOrInline: string): unknown { export async function cmdCasGet( storageRoot: string, hash: string, + opts: { timestamp?: boolean }, ): Promise { const store = openStore(storageRoot); const node = store.get(hash); if (node === null) { throw new Error(`Node not found: ${hash}`); } - return node; -} - -export async function cmdCasCat( - storageRoot: string, - hash: string, - opts: { payload?: boolean }, -): Promise { - const store = openStore(storageRoot); - const node = store.get(hash); - if (node === null) { - throw new Error(`Node not found: ${hash}`); + if (opts.timestamp) { + return node; } - return opts.payload ? node.payload : node; + const { timestamp: _, ...rest } = node as Record; + return rest; } export async function cmdCasPut(