Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &cobra.Command{ Use: "scopes", Short: "Show Synthient scopes and whether the current key has them", Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { if !slices.Contains(formats, flags.format) { timber.FatalMsgf("invalid output format %q; valid formats: %s", flags.format, strings.Join(formats, "|")) } granted := []string{} config, err := conf.Read() if err == nil { client, clientErr := auth.SynthientClient(config) if clientErr == nil { config.ApplyToClient(&client) account, accountErr := client.GetAccount(nil) if accountErr == nil { granted = account.Scopes } } } rows := []Row{} for _, scope := range access.Scopes { rows = append(rows, Row{ Scope: scope.Scope, Grants: scope.Grants, Granted: access.Has(granted, scope.Scope), }) } out, closeOut := output.Open(flags.output) defer closeOut() switch flags.format { case "text": writeText(out, rows) case "json": output.JSON(out, rows) case "csv": writer := csv.NewWriter(out) err := writer.Write([]string{"scope", "grants", "granted"}) if err != nil { app.Fatal(err, "failed to write csv header") } for _, row := range rows { err = writer.Write([]string{row.Scope, row.Grants, fmt.Sprint(row.Granted)}) if err != nil { app.Fatal(err, "failed to write csv row") } } writer.Flush() } }, }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.