Skip to content

Commit

Permalink
✨ cli: add editing_session parse to output key information (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
ericlinagora committed Sep 24, 2024
1 parent 1a43a75 commit d86165d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tdrive/backend/node/src/cli/cmds/editing_session_cmds/parse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import yargs from "yargs";

import { NonPlatformCommandYargsBuilder } from "../../utils/non-plaform-command-yargs-builder";
import { EditingSessionKeyFormat } from "../../../services/documents/entities/drive-file";

interface ParseArguments {
editing_session_key: string;
}

const command: yargs.CommandModule<unknown, unknown> = {
command: "parse <editing_session_key>",
describe: `
Parse the provided editing_session_key and output json data (to stderr)
`.trim(),

builder: {
...NonPlatformCommandYargsBuilder,
},
handler: async argv => {
const args = argv as unknown as ParseArguments;
const parsed = EditingSessionKeyFormat.parse(decodeURIComponent("" + args.editing_session_key));
console.error(
JSON.stringify(
{
ageH: (new Date().getTime() - parsed.timestamp.getTime()) / (60 * 60 * 1000),
...parsed,
},
null,
2,
),
);
},
};
export default command;

0 comments on commit d86165d

Please sign in to comment.