MCPcopy
hub / github.com/larksuite/cli / newRuntimeContext

Function newRuntimeContext

shortcuts/common/runner.go:1014–1032  ·  view source on GitHub ↗
(cmd *cobra.Command, f *cmdutil.Factory, s *Shortcut, config *core.CliConfig, as core.Identity, botOnly bool)

Source from the content-addressed store, hash-verified

1012}
1013
1014func 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

Callers 1

runShortcutFunction · 0.85

Calls 4

StrMethod · 0.95
ContextWithShortcutFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected