🩹 back cli: users subcommands argument capitalisation made consistent
This commit is contained in:
committed by
Anton Shepilov
parent
7856bf5096
commit
5e94c91c01
@@ -15,9 +15,9 @@ import { EntityByKind } from "../../utils/print-entities";
|
|||||||
let globalArgv: {
|
let globalArgv: {
|
||||||
verbose: boolean;
|
verbose: boolean;
|
||||||
|
|
||||||
user_id: string;
|
userId: string;
|
||||||
json_output: boolean;
|
jsonOutput: boolean;
|
||||||
with_storage_paths: boolean;
|
withStoragePaths: boolean;
|
||||||
|
|
||||||
user?: User; // Not an argument per say, hydrated in handler
|
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],
|
entity: Parameters<(typeof EntityByKind)[K]["headerOf"]>[0],
|
||||||
depth: number = 0,
|
depth: number = 0,
|
||||||
): string => {
|
): 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
|
// ts doesn't seem to infer entityHeaderPrinter[kind] correctly even with help
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
return `${kind.padEnd(lengthOfLongestEntityKind)} ${entity.id} ${new Array(depth + 1).join(
|
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(
|
const versionsAssets = await loadRawVersionsOfItemForDeletion(
|
||||||
repos,
|
repos,
|
||||||
item,
|
item,
|
||||||
globalArgv.with_storage_paths,
|
globalArgv.withStoragePaths,
|
||||||
);
|
);
|
||||||
for (const { version, file, paths } of versionsAssets) {
|
for (const { version, file, paths } of versionsAssets) {
|
||||||
const outputPath = (path: string) =>
|
const outputPath = (path: string) =>
|
||||||
console.log(entityToHeaderString("s3", { id: file.id, path }, depth + 2));
|
console.log(entityToHeaderString("s3", { id: file.id, path }, depth + 2));
|
||||||
if (globalArgv.json_output) {
|
if (globalArgv.jsonOutput) {
|
||||||
for (const path of paths || []) outputPath(path);
|
for (const path of paths || []) outputPath(path);
|
||||||
} else if (paths) {
|
} else if (paths) {
|
||||||
paths.sort((a, b) => a.localeCompare(b));
|
paths.sort((a, b) => a.localeCompare(b));
|
||||||
@@ -76,21 +76,21 @@ async function dumpAccount(repos: TUserDeletionRepos): Promise<number> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
command: "dump <user_id>",
|
command: "dump <userId>",
|
||||||
describe: "Output a list of entities related to a user",
|
describe: "Output a list of entities related to a user",
|
||||||
builder: {
|
builder: {
|
||||||
user_id: {
|
userId: {
|
||||||
demandOption: true,
|
demandOption: true,
|
||||||
type: "string",
|
type: "string",
|
||||||
describe:
|
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)",
|
"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",
|
type: "boolean",
|
||||||
alias: "j",
|
alias: "j",
|
||||||
describe: "Output in lines of '[kind] [json_object]'.",
|
describe: "Output in lines of '[kind] [json_object]'.",
|
||||||
},
|
},
|
||||||
with_storage_paths: {
|
withStoragePaths: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
alias: "p",
|
alias: "p",
|
||||||
describe: "If set, also query the storage to include all relevant paths in the output",
|
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 }) => {
|
await runWithPlatform("dump_account", async ({ spinner: _spinner, platform: _platform }) => {
|
||||||
const repos = await buildUserDeletionRepositories(gr.database, gr.platformServices.search);
|
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) {
|
if (!argv.user) {
|
||||||
console.error(`Error, unknown user ${JSON.stringify(argv.user_id)}`);
|
console.error(`Error, unknown user ${JSON.stringify(argv.userId)}`);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
await dumpAccount(repos);
|
await dumpAccount(repos);
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import { EntityByKind } from "../../utils/print-entities";
|
|||||||
let globalArgv: {
|
let globalArgv: {
|
||||||
verbose: boolean;
|
verbose: boolean;
|
||||||
|
|
||||||
email_like: string;
|
emailLike: string;
|
||||||
json_output: boolean;
|
jsonOutput: boolean;
|
||||||
|
|
||||||
user?: User; // Not an argument per say, hydrated in handler
|
user?: User; // Not an argument per say, hydrated in handler
|
||||||
};
|
};
|
||||||
@@ -19,7 +19,7 @@ const entityToHeaderString = <K extends keyof typeof EntityByKind>(
|
|||||||
kind: K & string,
|
kind: K & string,
|
||||||
entity: Parameters<(typeof EntityByKind)[K]["headerOf"]>[0],
|
entity: Parameters<(typeof EntityByKind)[K]["headerOf"]>[0],
|
||||||
): string => {
|
): 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
|
// ts doesn't seem to infer entityHeaderPrinter[kind] correctly even with help
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
return `${entity.id} ${EntityByKind[kind].headerOf(entity as any)}`;
|
return `${entity.id} ${EntityByKind[kind].headerOf(entity as any)}`;
|
||||||
@@ -29,13 +29,13 @@ export default {
|
|||||||
command: "list",
|
command: "list",
|
||||||
describe: "list users",
|
describe: "list users",
|
||||||
builder: {
|
builder: {
|
||||||
email_like: {
|
emailLike: {
|
||||||
alias: "e",
|
alias: "e",
|
||||||
type: "string",
|
type: "string",
|
||||||
describe:
|
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)",
|
"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",
|
type: "boolean",
|
||||||
alias: "j",
|
alias: "j",
|
||||||
describe: "Output in lines of '[kind] [json_object]'.",
|
describe: "Output in lines of '[kind] [json_object]'.",
|
||||||
@@ -54,7 +54,7 @@ export default {
|
|||||||
await repos.user.find(
|
await repos.user.find(
|
||||||
{},
|
{},
|
||||||
{
|
{
|
||||||
...(argv.email_like ? { $like: [["email_canonical", argv.email_like]] } : {}),
|
...(argv.emailLike ? { $like: [["email_canonical", argv.emailLike]] } : {}),
|
||||||
sort: { email_canonical: "asc" },
|
sort: { email_canonical: "asc" },
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user