-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ cli: add
editing_session parse
to output key information (#525)
- Loading branch information
1 parent
1a43a75
commit d86165d
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
tdrive/backend/node/src/cli/cmds/editing_session_cmds/parse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |