TypeScript command class can not store static variable and access it on the next call

Viewed 37

My class extends Command and i'm creating a static User: string member.

After my remote call, I store the returned string to that variable

When I try to access it from the cli again, the variable is Undefined although I stored it.

this is my class:

class CustomCLI extends Command {

  static User: string

  static flags = {

    connect: flags.string({
      char: 'c'
    }),

    user: flags.boolean({
      char: 'u'
    })
  }

  async run() {

    if (flags.connect) {
      //do stuff and store to 
      CustomCLI.User = "Returned String"
      //Access Given to Admin
    }

    if (flags.user) {
      //do stuff and store to 
      console.log(CustomCLI.User) //this is undefined
    }

  }

}

Execution example

enter image description here

0 Answers
Related