Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,15 @@ $ dbxcli search --output=json report /Reports
$ dbxcli revs --output=json /Reports/old.pdf
$ dbxcli cp --output=json /Reports/old.pdf /Reports/copy.pdf
$ dbxcli mv --output=json /Reports/copy.pdf /Reports/archive/copy.pdf
$ dbxcli put --output=json README.md /README.md
$ dbxcli share-link create --output=json /Reports/old.pdf
$ dbxcli share-link list --output=json /Reports/old.pdf
$ dbxcli mkdir --output=json /new-folder
$ dbxcli rm --output=json /old-file.txt
$ dbxcli restore --output=json /Reports/old.pdf 015f...
```

Structured success output is rolling out command by command. Currently migrated commands are `account`, `du`, `ls`, `search`, `revs`, `cp`, `mv`, `share-link create`, `share-link list`, `share-link info`, `share-link update`, `share-link revoke`, `share-link download`, `mkdir`, `rm`, and `restore`. Commands that have not been migrated return a JSON error whose `error.message` is `structured output is not supported for this command yet` when used with `--output=json`.
Structured success output is rolling out command by command. Currently migrated commands are `account`, `du`, `ls`, `search`, `revs`, `cp`, `mv`, `put`, `share-link create`, `share-link list`, `share-link info`, `share-link update`, `share-link revoke`, `share-link download`, `mkdir`, `rm`, and `restore`. Commands that have not been migrated return a JSON error whose `error.message` is `structured output is not supported for this command yet` when used with `--output=json`.

Command results are written to stdout. Status, progress, warnings, diagnostics, and verbose logs are written to stderr.

Expand Down Expand Up @@ -221,6 +222,38 @@ For commands such as `rm`, `input` uses command-specific path and flag fields:
}
```

`put` always returns a `results` array, including single-file and stdin uploads. The top-level `input` describes the command request; each result reports whether a file was `uploaded`, `skipped`, or a directory was `created` or already `existing`:

```json
{
"input": {
"source": "README.md",
"target": "/README.md",
"recursive": false,
"if_exists": "overwrite",
"stdin": false
},
"results": [
{
"status": "uploaded",
"kind": "file",
"input": {
"source": "README.md",
"target": "/README.md"
},
"result": {
"type": "file",
"path_display": "/README.md",
"path_lower": "/readme.md",
"id": "id:...",
"rev": "...",
"size": 123
}
}
]
}
```

Commands that return entry lists, such as `ls`, `search`, and `revs`, return an `input` object and an `entries` array. `ls` input includes the listed path; `search` input includes the query and optional path scope; `revs` input includes the file path:

```json
Expand Down
9 changes: 9 additions & 0 deletions cmd/json_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ type jsonMetadata struct {
func jsonMetadataFromDropbox(metadata files.IsMetadata) jsonMetadata {
switch m := metadata.(type) {
case *files.FileMetadata:
if m == nil {
return jsonMetadata{Type: "unknown"}
}
size := m.Size
return jsonMetadata{
Type: "file",
Expand All @@ -33,13 +36,19 @@ func jsonMetadataFromDropbox(metadata files.IsMetadata) jsonMetadata {
ClientModified: jsonTime(m.ClientModified),
}
case *files.FolderMetadata:
if m == nil {
return jsonMetadata{Type: "unknown"}
}
return jsonMetadata{
Type: "folder",
PathDisplay: m.PathDisplay,
PathLower: m.PathLower,
ID: m.Id,
}
case *files.DeletedMetadata:
if m == nil {
return jsonMetadata{Type: "unknown"}
}
return jsonMetadata{
Type: "deleted",
PathDisplay: m.PathDisplay,
Expand Down
Loading
Loading