Просмотр исходного кода

Add more detail for the modes

GitOrigin-RevId: 44b63b76b1edb8bfb78049c9c8560934e340ef96
Andrew Rumble 1 год назад
Родитель
Сommit
745043ca92
1 измененных файлов с 18 добавлено и 1 удалено
  1. 18 1
      services/history-v1/storage/scripts/recover_zip_from_backup.mjs

+ 18 - 1
services/history-v1/storage/scripts/recover_zip_from_backup.mjs

@@ -14,12 +14,24 @@ import { client } from '../lib/mongodb.js'
 import archiver from 'archiver'
 import Events from 'node:events'
 import { Chunk } from 'overleaf-editor-core'
+import _ from 'lodash'
 
 // Silence warning.
 Events.setMaxListeners(20)
 
 const SUPPORTED_MODES = ['raw', 'latest']
 
+// Pads the mode name to a fixed length for better alignment in output.
+const padModeName = _.partialRight(
+  _.padEnd,
+  Math.max(...SUPPORTED_MODES.map(mode => mode.length))
+)
+
+const SUPPORTED_MODES_HELP = {
+  raw: 'Retrieve all chunk and blob files from the project backup.',
+  latest: 'Retrieves the last backed up state of the project.',
+}
+
 // outputFile needs to be available in the shutdown function (which may be called before it's declared)
 // eslint-disable-next-line prefer-const
 let outputFile
@@ -42,10 +54,15 @@ function usage() {
   console.log(
     'Usage: node recover_zip_from_backup.mjs --historyId=<historyId> --output=<output> [--mode=<mode>] [--verbose] [--useBackupGlobalBlobs]'
   )
-  console.log('Supported modes: ' + SUPPORTED_MODES.join(', '))
   console.log(
     '--useBackupGlobalBlobs can be used if the global blobs have not been restored from the backup yet.'
   )
+  console.log('Supported modes: ' + SUPPORTED_MODES.join(', '))
+  SUPPORTED_MODES.forEach(mode => {
+    console.log(
+      `    --mode=${padModeName(mode)} -  ${SUPPORTED_MODES_HELP[mode] || ''}`
+    )
+  })
 }
 
 /**