From 5e94c91c01a3d9039ff6c8b220b3eb6f58757a07 Mon Sep 17 00:00:00 2001 From: Eric Doughty-Papassideris Date: Sun, 2 Mar 2025 18:59:57 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20back=20cli:=20users=20subcommand?= =?UTF-8?q?s=20argument=20capitalisation=20made=20consistent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../node/src/cli/cmds/users_cmds/dump.ts | 24 +++++++++---------- .../node/src/cli/cmds/users_cmds/list.ts | 12 +++++----- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tdrive/backend/node/src/cli/cmds/users_cmds/dump.ts b/tdrive/backend/node/src/cli/cmds/users_cmds/dump.ts index f8d70070..cc37daf2 100644 --- a/tdrive/backend/node/src/cli/cmds/users_cmds/dump.ts +++ b/tdrive/backend/node/src/cli/cmds/users_cmds/dump.ts @@ -15,9 +15,9 @@ import { EntityByKind } from "../../utils/print-entities"; let globalArgv: { verbose: boolean; - user_id: string; - json_output: boolean; - with_storage_paths: boolean; + userId: string; + jsonOutput: boolean; + withStoragePaths: boolean; user?: User; // Not an argument per say, hydrated in handler }; @@ -32,7 +32,7 @@ const entityToHeaderString = ( entity: Parameters<(typeof EntityByKind)[K]["headerOf"]>[0], depth: number = 0, ): string => { - if (globalArgv.json_output) return kind + " " + JSON.stringify(entity); // Can't really print out json directly, valid json seems to get prettified by pino + if (globalArgv.jsonOutput) return kind + " " + JSON.stringify(entity); // Can't really print out json directly, valid json seems to get prettified by pino // ts doesn't seem to infer entityHeaderPrinter[kind] correctly even with help // eslint-disable-next-line @typescript-eslint/no-explicit-any return `${kind.padEnd(lengthOfLongestEntityKind)} ${entity.id} ${new Array(depth + 1).join( @@ -51,12 +51,12 @@ async function dumpAccount(repos: TUserDeletionRepos): Promise { const versionsAssets = await loadRawVersionsOfItemForDeletion( repos, item, - globalArgv.with_storage_paths, + globalArgv.withStoragePaths, ); for (const { version, file, paths } of versionsAssets) { const outputPath = (path: string) => console.log(entityToHeaderString("s3", { id: file.id, path }, depth + 2)); - if (globalArgv.json_output) { + if (globalArgv.jsonOutput) { for (const path of paths || []) outputPath(path); } else if (paths) { paths.sort((a, b) => a.localeCompare(b)); @@ -76,21 +76,21 @@ async function dumpAccount(repos: TUserDeletionRepos): Promise { } export default { - command: "dump ", + command: "dump ", describe: "Output a list of entities related to a user", builder: { - user_id: { + userId: { demandOption: true, type: "string", describe: "id of the user, or a search string for the email.\n(if the id doesn't match, will print the matching users and exit)", }, - json_output: { + jsonOutput: { type: "boolean", alias: "j", describe: "Output in lines of '[kind] [json_object]'.", }, - with_storage_paths: { + withStoragePaths: { type: "boolean", alias: "p", describe: "If set, also query the storage to include all relevant paths in the output", @@ -104,9 +104,9 @@ export default { } await runWithPlatform("dump_account", async ({ spinner: _spinner, platform: _platform }) => { const repos = await buildUserDeletionRepositories(gr.database, gr.platformServices.search); - argv.user = await repos.user.findOne({ id: argv.user_id }); + argv.user = await repos.user.findOne({ id: argv.userId }); if (!argv.user) { - console.error(`Error, unknown user ${JSON.stringify(argv.user_id)}`); + console.error(`Error, unknown user ${JSON.stringify(argv.userId)}`); return 1; } await dumpAccount(repos); diff --git a/tdrive/backend/node/src/cli/cmds/users_cmds/list.ts b/tdrive/backend/node/src/cli/cmds/users_cmds/list.ts index 65541c6d..d1f5fcca 100644 --- a/tdrive/backend/node/src/cli/cmds/users_cmds/list.ts +++ b/tdrive/backend/node/src/cli/cmds/users_cmds/list.ts @@ -9,8 +9,8 @@ import { EntityByKind } from "../../utils/print-entities"; let globalArgv: { verbose: boolean; - email_like: string; - json_output: boolean; + emailLike: string; + jsonOutput: boolean; user?: User; // Not an argument per say, hydrated in handler }; @@ -19,7 +19,7 @@ const entityToHeaderString = ( kind: K & string, entity: Parameters<(typeof EntityByKind)[K]["headerOf"]>[0], ): string => { - if (globalArgv.json_output) return kind + " " + JSON.stringify(entity); // Can't really print out json directly, valid json seems to get prettified by pino + if (globalArgv.jsonOutput) return kind + " " + JSON.stringify(entity); // Can't really print out json directly, valid json seems to get prettified by pino // ts doesn't seem to infer entityHeaderPrinter[kind] correctly even with help // eslint-disable-next-line @typescript-eslint/no-explicit-any return `${entity.id} ${EntityByKind[kind].headerOf(entity as any)}`; @@ -29,13 +29,13 @@ export default { command: "list", describe: "list users", builder: { - email_like: { + emailLike: { alias: "e", type: "string", describe: "id of the user, or a search string for the email.\n(if the id doesn't match, will print the matching users and exit)", }, - json_output: { + jsonOutput: { type: "boolean", alias: "j", describe: "Output in lines of '[kind] [json_object]'.", @@ -54,7 +54,7 @@ export default { await repos.user.find( {}, { - ...(argv.email_like ? { $like: [["email_canonical", argv.email_like]] } : {}), + ...(argv.emailLike ? { $like: [["email_canonical", argv.emailLike]] } : {}), sort: { email_canonical: "asc" }, }, )