github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/internal/runners/export/jwt.go (about) 1 package export 2 3 import ( 4 "github.com/ActiveState/cli/internal/locale" 5 "github.com/ActiveState/cli/internal/logging" 6 "github.com/ActiveState/cli/internal/output" 7 "github.com/ActiveState/cli/pkg/platform/authentication" 8 ) 9 10 type JWT struct { 11 output.Outputer 12 *authentication.Auth 13 } 14 15 func NewJWT(prime primeable) *JWT { 16 return &JWT{prime.Output(), prime.Auth()} 17 } 18 19 type JWTParams struct { 20 } 21 22 // Run processes the `export recipe` command. 23 func (j *JWT) Run(params *JWTParams) error { 24 logging.Debug("Execute") 25 26 if !j.Auth.Authenticated() { 27 return locale.NewInputError("err_jwt_not_authenticated") 28 } 29 30 token := j.Auth.BearerToken() 31 j.Outputer.Print(output.Prepare( 32 token, 33 &struct { 34 Value string `json:"value"` 35 }{token}, 36 )) 37 return nil 38 }