MCPcopy Create free account
hub / github.com/dropbox/dbxcli / initCommandContext

Function initCommandContext

cmd/root.go:67–88  ·  view source on GitHub ↗
(cmd *cobra.Command)

Source from the content-addressed store, hash-verified

65}
66
67func initCommandContext(cmd *cobra.Command) error {
68 finishCommandContext()
69
70 ctx := cmd.Context()
71 if ctx == nil {
72 ctx = context.Background()
73 }
74
75 timeout, err := commandTimeout(cmd)
76 if err != nil {
77 return err
78 }
79 if timeout < 0 {
80 return invalidArgumentsErrorWithDetails("`--timeout` must be greater than or equal to 0", flagErrorDetails("timeout"))
81 }
82 if timeout > 0 {
83 ctx, commandContextCancel = context.WithTimeout(ctx, timeout)
84 cmd.SetContext(ctx)
85 }
86 commandContext = ctx
87 return nil
88}
89
90func commandTimeout(cmd *cobra.Command) (time.Duration, error) {
91 for _, flags := range []interface {

Callers 5

login.goFile · 0.85
initDbxFunction · 0.85
logout.goFile · 0.85

Calls 4

finishCommandContextFunction · 0.85
commandTimeoutFunction · 0.85
flagErrorDetailsFunction · 0.85