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
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# `dbxcli`: Dropbox from the command line

[![CI](https://github.com/dropbox/dbxcli/actions/workflows/ci.yml/badge.svg)](https://github.com/dropbox/dbxcli/actions/workflows/ci.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/dropbox/dbxcli/v3)](https://goreportcard.com/report/github.com/dropbox/dbxcli/v3)
[![Go Report Card](https://goreportcard.com/badge/github.com/dropbox/dbxcli/v3?cache=v3)](https://goreportcard.com/report/github.com/dropbox/dbxcli/v3)

`dbxcli` is a scriptable Dropbox CLI for files, shared links, teams, and
automation workflows. It is built for humans at the terminal, scripts, CI jobs,
Expand Down Expand Up @@ -34,6 +34,9 @@ dbxcli --help --output=json
dbxcli put --help --output=json
```

Stable JSON error codes and process exit codes are documented in
[Automation and JSON output](https://github.com/dropbox/dbxcli/blob/master/docs/automation.md).

## Common workflows

Upload a file:
Expand Down Expand Up @@ -66,12 +69,20 @@ Create a shared link:
dbxcli share-link create /Reports/report.pdf
```

Use JSON output:
In text mode, `share-link create` prints only the shared-link URL to stdout:

```sh
dbxcli ls --output=json /
url="$(dbxcli share-link create /Reports/report.pdf)"
```

## Troubleshooting

### Why can uploading to `/remote.txt` fail on team accounts?

Some team accounts may not have a writable Dropbox root namespace. Run
`dbxcli ls /` first, then upload under a writable folder, such as your personal
folder or a team folder.

## Features

* File operations: `ls`, `cp`, `mkdir`, `mv`, `rm`, `put`, and `get`
Expand Down Expand Up @@ -174,8 +185,8 @@ dbxcli put --help --output=json
* [JSON schema v1](https://github.com/dropbox/dbxcli/blob/master/docs/json-schema/v1/README.md)
* [Release history](https://github.com/dropbox/dbxcli/blob/master/CHANGELOG.md)

Generated Cobra command docs live under `docs/commands/` and are kept close to
the actual CLI by `go run ./tools/gen-docs`.
Generated Cobra command docs live under `docs/commands/`, and CI verifies they
stay in sync with the CLI.

## Contributing

Expand Down
5 changes: 5 additions & 0 deletions cmd/help_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ func setCommandDestructiveLevel(cmd *cobra.Command, level string) {
setCommandAnnotationList(cmd, commandDestructiveLevelAnnotation, []string{level})
}

// CommandManifestAuthModes returns the auth modes published in JSON help.
func CommandManifestAuthModes(cmd *cobra.Command) []string {
return commandManifestAuthModes(cmd)
}

func setCommandAnnotationList(cmd *cobra.Command, key string, values []string) {
if cmd.Annotations == nil {
cmd.Annotations = make(map[string]string)
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ manage your team and more. It is easy, scriptable and works on all platforms!

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dbxcli account [flags] [<account-id>]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dbxcli completion [bash|zsh|fish|powershell] [flags]

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_completion_bash.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dbxcli completion bash

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_completion_fish.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dbxcli completion fish [flags]

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_completion_powershell.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dbxcli completion powershell [flags]

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_completion_zsh.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ dbxcli completion zsh [flags]

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_cp.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dbxcli cp [flags] <source> [more sources] <target>

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_du.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dbxcli du [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_get.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dbxcli get [flags] <source> [<target>]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`
* Stdin/stdout behavior: Use `-` as the local target to write downloaded file bytes to stdout; diagnostics go to stderr.


Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dbxcli login [personal|team-access|team-manage] [flags]

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_logout.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ dbxcli logout [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_ls.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ dbxcli ls [flags] [<path>]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_mkdir.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dbxcli mkdir [flags] <directory>

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_mv.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dbxcli mv [flags] <source> <target>

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_put.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dbxcli put [flags] <source> [<target>]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`
* Stdin/stdout behavior: Use `-` as the local source to upload from stdin; stdin is spooled to a temporary file before upload.


Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dbxcli restore [flags] <target-path> <revision>

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_revs.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dbxcli revs [flags] <file>

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_rm.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dbxcli rm [flags] <file>

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`
* Destructive behavior: `delete`


Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_search.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ dbxcli search [flags] <query> [path-scope]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_share-link.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Create, list, inspect, download, update, and revoke Dropbox shared links.

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_share-link_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ dbxcli share-link create <path> [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_share-link_download.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dbxcli share-link download <url> [target] [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`
* Stdin/stdout behavior: Use `-` as the target for file shared links to write bytes to stdout; folder shared links require `--recursive` and cannot be written to stdout.


Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_share-link_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dbxcli share-link info <url> [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_share-link_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dbxcli share-link list [path] [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_share-link_revoke.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ dbxcli share-link revoke [url] [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_share-link_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dbxcli share-link update <url> [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_share.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Sharing commands

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_share_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ List shared things

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_share_list_folder.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dbxcli share list folder [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `personal`, `team-access`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_team.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Team management commands

* Structured JSON output: no
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_team_add-member.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dbxcli team add-member [flags] <email> <first-name> <last-name>

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `team-manage`
* Destructive behavior: `admin`


Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_team_info.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dbxcli team info [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `team-manage`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_team_list-groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dbxcli team list-groups [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `team-manage`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_team_list-members.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dbxcli team list-members [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `team-manage`


### SEE ALSO
Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_team_remove-member.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dbxcli team remove-member [flags] <email>

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: `team-manage`
* Destructive behavior: `admin`


Expand Down
1 change: 1 addition & 0 deletions docs/commands/dbxcli_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dbxcli version [flags]

* Structured JSON output: yes
* JSON help manifest: yes
* Auth modes: none


### SEE ALSO
Expand Down
12 changes: 12 additions & 0 deletions tools/gen-docs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ func commandMetadataSection(command *cobra.Command) []byte {
buf.WriteString("### Command metadata\n\n")
buf.WriteString(fmt.Sprintf("* Structured JSON output: %s\n", yesNo(commandSupportsStructuredOutput(command))))
buf.WriteString("* JSON help manifest: yes\n")
buf.WriteString("* Auth modes: " + markdownValueList(cmd.CommandManifestAuthModes(command)) + "\n")

if aliases := sortedAliases(command); len(aliases) > 0 {
buf.WriteString("* Aliases: ")
Expand Down Expand Up @@ -218,3 +219,14 @@ func yesNo(value bool) string {
}
return "no"
}

func markdownValueList(values []string) string {
if len(values) == 0 {
return "none"
}
quoted := make([]string, 0, len(values))
for _, value := range values {
quoted = append(quoted, "`"+value+"`")
}
return strings.Join(quoted, ", ")
}
Loading