|
@@ -1,28 +1,44 @@
|
|
|
-import {run as apiRun} from '../../../helpers/api'
|
|
|
-import {Command, flags} from '@oclif/command'
|
|
|
+import { createStorageBucket } from '../../../services/api'
|
|
|
+import { Command, flags } from '@oclif/command'
|
|
|
|
|
|
export default class WgLeaderCreateBucket extends Command {
|
|
|
- static description = 'Create storage bucket.'
|
|
|
+ static description = `Create new storage bucket. Requires storage working group leader permissions.`
|
|
|
|
|
|
static flags = {
|
|
|
- help: flags.help({char: 'h'}),
|
|
|
- // flag with a value (-n, --name=VALUE)
|
|
|
- name: flags.string({char: 'n', description: 'name to print'}),
|
|
|
- // flag with no value (-f, --force)
|
|
|
- force: flags.boolean({char: 'f'}),
|
|
|
+ help: flags.help({ char: 'h' }),
|
|
|
+ size: flags.integer({
|
|
|
+ char: 's',
|
|
|
+ description: 'Storage bucket max total objects size',
|
|
|
+ }),
|
|
|
+ number: flags.integer({
|
|
|
+ char: 'n',
|
|
|
+ description: 'Storage bucket max total objects number',
|
|
|
+ }),
|
|
|
+ allow: flags.boolean({ char: 'a', description: 'Accepts new bags' }),
|
|
|
+ dev: flags.boolean({ char: 'd', description: 'Development API' }),
|
|
|
}
|
|
|
|
|
|
- static args = [{name: 'file'}]
|
|
|
+ static args = [{ name: 'file' }]
|
|
|
|
|
|
async run() {
|
|
|
- const {args, flags} = this.parse(WgLeaderCreateBucket)
|
|
|
+ const { flags } = this.parse(WgLeaderCreateBucket)
|
|
|
|
|
|
- const name = flags.name ?? 'world'
|
|
|
- this.log(`Create storage bucket: ${name} `)
|
|
|
- if (args.file && flags.force) {
|
|
|
- this.log(`you input --force and --file: ${args.file}`)
|
|
|
+ const objectSize = flags.size ?? 0
|
|
|
+ const objectNumber = flags.number ?? 0
|
|
|
+ const allowNewBags = flags.allow ?? true
|
|
|
+
|
|
|
+ this.log('Creating storage bucket...')
|
|
|
+ if (flags.dev) {
|
|
|
+ this.log('development mode is ON')
|
|
|
}
|
|
|
|
|
|
- await apiRun()
|
|
|
+ await createStorageBucket(null, allowNewBags, objectSize, objectNumber)
|
|
|
+ }
|
|
|
+
|
|
|
+ async finally(err: any) {
|
|
|
+ // called after run and catch regardless of whether or not the command errored
|
|
|
+ // We'll force exit here, in case there is no error, to prevent console.log from hanging the process
|
|
|
+ if (!err) this.exit(0)
|
|
|
+ super.finally(err)
|
|
|
}
|
|
|
}
|