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

Function restore

cmd/restore.go:43–75  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

41}
42
43func restore(cmd *cobra.Command, args []string) (err error) {
44 if len(args) != 2 {
45 return invalidArgumentsErrorWithDetails("`restore` requires `target-path` and `revision` arguments", argumentsErrorDetails("target-path", "revision"))
46 }
47
48 path, err := validatePath(args[0])
49 if err != nil {
50 return
51 }
52
53 rev := args[1]
54
55 arg := files.NewRestoreArg(path, rev)
56
57 dbx := filesNewFunc(config)
58 metadata, err := dbx.RestoreContext(currentContext(), arg)
59 if err != nil {
60 return withJSONErrorDetails(err, restoreErrorDetails(path, rev))
61 }
62
63 verbose, _ := cmd.Flags().GetBool("verbose")
64 result, err := newRestoreResult(path, rev, metadata)
65 if err != nil {
66 return withJSONErrorDetails(err, restoreErrorDetails(path, rev))
67 }
68
69 return commandOutput(cmd).Render(func(w io.Writer) error {
70 if !verbose {
71 return nil
72 }
73 return renderRestoreResult(w, result)
74 }, newJSONCommandOperationOutput(cmd, result.Input, []jsonOperationResult{restoreOperationResult(result)}, nil))
75}
76
77func restoreErrorDetails(path, revision string) map[string]any {
78 return mergeJSONErrorDetails(operationErrorDetails("restore"), pathErrorDetails(path), revisionErrorDetails(revision))

Calls 13

argumentsErrorDetailsFunction · 0.85
validatePathFunction · 0.85
currentContextFunction · 0.85
withJSONErrorDetailsFunction · 0.85
restoreErrorDetailsFunction · 0.85
newRestoreResultFunction · 0.85
commandOutputFunction · 0.85
renderRestoreResultFunction · 0.85
restoreOperationResultFunction · 0.85
RenderMethod · 0.80