🩹 back cli: users subcommands argument capitalisation made consistent

This commit is contained in:
Eric Doughty-Papassideris
2025-03-02 18:59:57 +01:00
committed by Anton Shepilov
parent 7856bf5096
commit 5e94c91c01
2 changed files with 18 additions and 18 deletions
@@ -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 = <K extends keyof typeof EntityByKind>(
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<number> {
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<number> {
}
export default {
command: "dump <user_id>",
command: "dump <userId>",
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);
@@ -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 = <K extends keyof typeof EntityByKind>(
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" },
},
)