async init()

in src/base-commands/http.ts [18:39]


  async init() {
    const { flags } = await this.parse(HttpCommand)

    const configuration = new Configuration()
    const profile = configuration.getProfile(flags.profile)

    if (profile) {
      this.profile = profile
      this.http = new Http(profile.apiKey)
    } else {
      const addConfigNow = await CliUx.ux.confirm(`No configuration found for profile ${flags.profile}. Add one now?`)

      if (addConfigNow) {
        const newProfile = await ConfigurationAdd.run(['-p', flags.profile, '-x'])
        this.profile = newProfile
        this.http = new Http(newProfile.apiKey)
      } else {
        this.log(`To add a configuration, run ${ConfigurationAdd.id}`)
        this.exit(1)
      }
    }
  }