(cmd *cobra.Command, f *cmdutil.Factory, s *Shortcut, config *core.CliConfig, as core.Identity, botOnly bool)
| 1012 | } |
| 1013 | |
| 1014 | func newRuntimeContext(cmd *cobra.Command, f *cmdutil.Factory, s *Shortcut, config *core.CliConfig, as core.Identity, botOnly bool) (*RuntimeContext, error) { |
| 1015 | ctx := cmd.Context() |
| 1016 | ctx = cmdutil.ContextWithShortcut(ctx, s.Service+":"+s.Command, uuid.New().String()) |
| 1017 | rctx := &RuntimeContext{ctx: ctx, Config: config, Cmd: cmd, botOnly: botOnly, resolvedAs: as, Factory: f} |
| 1018 | rctx.apiClientFunc = sync.OnceValues(func() (*client.APIClient, error) { |
| 1019 | return f.NewAPIClientWithConfig(config) |
| 1020 | }) |
| 1021 | rctx.botInfoFunc = sync.OnceValues(rctx.fetchBotInfo) |
| 1022 | |
| 1023 | sdk, err := f.LarkClient() |
| 1024 | if err != nil { |
| 1025 | return nil, err |
| 1026 | } |
| 1027 | rctx.larkSDK = sdk |
| 1028 | |
| 1029 | rctx.Format = rctx.Str("format") |
| 1030 | rctx.JqExpr, _ = cmd.Flags().GetString("jq") |
| 1031 | return rctx, nil |
| 1032 | } |
| 1033 | |
| 1034 | // stripUTF8BOM removes a leading UTF-8 byte-order mark from content read from a |
| 1035 | // file or stdin. A BOM that survives into a CSV cell corrupts the first value |
no test coverage detected