Skip to content
Closed
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
8 changes: 3 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
language: go

go:
- "1.11.x"

before_script:
- go get -u github.com/mitchellh/gox
- env GO111MODULE=on go vet ./...
- "1.25.x"

install: true

script:
- go vet ./...
- go test ./...
- ./build.sh

deploy:
Expand Down
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `dbxcli`: A command line tool for Dropbox users and team admins [UNOFFICIAL]

[![Build Status](https://travis-ci.org/dropbox/dbxcli.svg?branch=master)](https://travis-ci.org/dropbox/dbxcli)
[![Build Status](https://app.travis-ci.com/dropbox/dbxcli.svg?branch=master)](https://app.travis-ci.com/dropbox/dbxcli)
[![Go Report Card](https://goreportcard.com/badge/github.com/dropbox/dbxcli)](https://goreportcard.com/report/github.com/dropbox/dbxcli)

:warning: WARNING: This project is **NOT official**. What does this mean?
Expand Down Expand Up @@ -49,18 +49,25 @@ $ chmod +x dbxcli
### Instructions for building yourself
For newcomers the go build process can be a bit arcane, these steps can be followed to build `dbxcli` yourself.

1. Make sure `git`, `go`, and `gox` are installed.
2. Create a Go folder. For example, `mkdir $HOME/go` or `mkdir $HOME/.go`. Navigate to it.
3. `go get github.com/dropbox/dbxcli`. That's right, you don't manually clone it, this does it for you.
4. `cd ~/go/src/github.com/dropbox/dbxcli` (adapt accordingly based on step 2).
1. Make sure `git` and `go` are installed.
2. Install the latest released version:
```sh
$ go install github.com/dropbox/dbxcli@latest
```
3. Or build from source:
```sh
$ git clone https://github.com/dropbox/dbxcli.git
$ cd dbxcli
$ go build .
```

To use your own Dropbox app while developing, provide its app key when logging in:

To use your own Dropbox app while developing, provide its app key when running
`dbxcli`:
```sh
$ export DROPBOX_PERSONAL_APP_KEY=your-app-key
$ dbxcli login --app-key=your-app-key
```

Finally we're ready to build. Run `go build`, and you'll see a `dbxcli` binary has been created in the current directory. Congrats, we're done!
If you built from source, the `go build .` command creates a `dbxcli` binary in the current directory.

## Usage

Expand Down
28 changes: 18 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#!/bin/bash

LDFLAGS="-s -w -X main.version=${TRAVIS_TAG:-TRAVIS_COMMIT}"
LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.personalAppKey=${PERSONAL_KEY}"
LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.personalAppSecret=${PERSONAL_SECRET}"
LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.teamAccessAppKey=${ACCESS_KEY}"
LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.teamAccessAppSecret=${ACCESS_SECRET}"
LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.teamManageAppKey=${MANAGE_KEY}"
LDFLAGS+=" -X github.com/dropbox/dbxcli/cmd.teamManageAppSecret=${MANAGE_SECRET}"
GO111MODULE=on gox -ldflags="${LDFLAGS}" \
-osarch="darwin/amd64 linux/amd64 windows/amd64 linux/arm openbsd/amd64" \
-output "dist/{{.Dir}}-{{.OS}}-{{.Arch}}"
set -e

LDFLAGS="-s -w -X main.version=${TRAVIS_TAG:-${TRAVIS_COMMIT:-dev}}"

TARGETS="darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 linux/arm openbsd/amd64 windows/amd64"

mkdir -p dist

for target in $TARGETS; do
GOOS="${target%/*}"
GOARCH="${target#*/}"
output="dist/dbxcli-${GOOS}-${GOARCH}"
if [ "$GOOS" = "windows" ]; then
output="${output}.exe"
fi
echo "Building ${target}..."
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="${LDFLAGS}" -o "$output" .
done