upload.ts 902 B

12345678910111213141516171819202122232425262728293031
  1. import {Command, flags} from '@oclif/command'
  2. import { uploadDataObjects } from '../../services/extrinsics'
  3. export default class DevUpload extends Command {
  4. static description = 'describe the command here'
  5. static flags = {
  6. help: flags.help({char: 'h'}),
  7. dev: flags.boolean({ char: 'd', description: 'Use development mode' }),
  8. }
  9. static args = [{name: 'file'}]
  10. async run(): Promise<void> {
  11. const { flags } = this.parse(DevUpload)
  12. this.log('Uploading data objects...')
  13. if (flags.dev) {
  14. this.log('development mode is ON')
  15. }
  16. await uploadDataObjects()
  17. }
  18. async finally(err: Error | undefined): Promise<void> {
  19. // called after run and catch regardless of whether or not the command errored
  20. // We'll force exit here, in case there is no error, to prevent console.log from hanging the process
  21. if (!err) this.exit(0)
  22. super.finally(err)
  23. }
  24. }