diff --git a/.gitignore b/.gitignore index c79ac120a..b2ba1c6bc 100644 --- a/.gitignore +++ b/.gitignore @@ -50,4 +50,5 @@ big-upload-testfile big-download-testfile small-upload-testfile small-download-testfile -/bin \ No newline at end of file +/bin +resource.syso diff --git a/Makefile b/Makefile index d9eada734..af199ccce 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ GO_VERSION ?= 1.11 GOOS ?= linux GOARCH ?= amd64 COMPOSE_PROJECT_NAME := ${TAG}-$(shell git rev-parse --abbrev-ref HEAD) -BRANCH := $(shell git rev-parse --abbrev-ref HEAD) +BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed "s!/!-!g") ifeq (${BRANCH},master) TAG := $(shell git rev-parse --short HEAD)-go${GO_VERSION} else @@ -109,6 +109,14 @@ binary: @if [ -z "${COMPONENT}" ]; then echo "Try one of the following targets instead:" \ && for b in binaries ${BINARIES}; do echo "- $$b"; done && exit 1; fi mkdir -p release/${TAG} + rm -f cmd/${COMPONENT}/resource.syso + if [ "${GOARCH}" = "amd64" ]; then sixtyfour="-64"; fi; \ + goversioninfo $$sixtyfour -o cmd/${COMPONENT}/resource.syso \ + -original-name ${COMPONENT}_${GOOS}_${GOARCH}${FILEEXT} \ + -description "${COMPONENT} program for Storj" \ + -product-ver-build 2 -ver-build 2 \ + -product-version "alpha2" \ + resources/versioninfo.json || echo "goversioninfo is not installed, metadata will not be created" tar -c . | docker run --rm -i -e TAR=1 -e GO111MODULE=on \ -e GOOS=${GOOS} -e GOARCH=${GOARCH} -e CGO_ENABLED=1 \ -w /go/src/storj.io/storj storjlabs/golang \ diff --git a/cmd/captplanet/main.go b/cmd/captplanet/main.go index 89098f7f2..b7d3b8804 100644 --- a/cmd/captplanet/main.go +++ b/cmd/captplanet/main.go @@ -33,7 +33,6 @@ var ( func main() { go dumpHandler() - // process.Exec will load this for this command. runCmd.Flags().String("config", filepath.Join(defaultConfDir, "config.yaml"), "path to configuration") diff --git a/pkg/process/exec.go b/pkg/process/exec.go index b43e00c6a..fdb86b848 100644 --- a/pkg/process/exec.go +++ b/pkg/process/exec.go @@ -4,10 +4,26 @@ package process import ( + "fmt" "log" "os" + + "github.com/spf13/cobra" ) +func init() { + + cobra.MousetrapHelpText = "This is a command line tool.\n\n" + + "This needs to be run from a Command Prompt.\n" + + // Figure out the executable name. + exe, err := os.Executable() + if err == nil { + cobra.MousetrapHelpText += fmt.Sprintf( + "Try running \"%s help\" for more information\n", exe) + } +} + // check if file exists, handle error correctly if it doesn't func fileExists(path string) bool { _, err := os.Stat(path) diff --git a/pkg/process/exec_conf.go b/pkg/process/exec_conf.go index 8e4d05283..a0e479ef6 100644 --- a/pkg/process/exec_conf.go +++ b/pkg/process/exec_conf.go @@ -31,6 +31,11 @@ func ExecuteWithConfig(cmd *cobra.Command, defaultConfig string) { // Exec runs a Cobra command. If a "config" flag is defined it will be parsed // and loaded using viper. func Exec(cmd *cobra.Command) { + exe, err := os.Executable() + if err == nil { + cmd.Use = exe + } + pflag.CommandLine.AddGoFlagSet(flag.CommandLine) cleanup(cmd) _ = cmd.Execute() diff --git a/resources/README.md b/resources/README.md new file mode 100644 index 000000000..b0d50deea --- /dev/null +++ b/resources/README.md @@ -0,0 +1,12 @@ +Resources +========= + +* icon.ico: compiled icon from icon.png + To recreate: +``` +convert icon.png -resize 256x256 -define icon:auto-resize="16,32,48,64,96,128,256" icon.ico +``` +* icon.png: icon stolen from storjshare-gui +* logo.png: logo previously in logo/ +* versioninfo.json: template file needed for goversioninfo, to add to windows + binaries. diff --git a/resources/icon.ico b/resources/icon.ico new file mode 100644 index 000000000..2bd1ac334 Binary files /dev/null and b/resources/icon.ico differ diff --git a/resources/icon.png b/resources/icon.png new file mode 100644 index 000000000..6a69fdaaf Binary files /dev/null and b/resources/icon.png differ diff --git a/logo/logo.png b/resources/logo.png similarity index 100% rename from logo/logo.png rename to resources/logo.png diff --git a/resources/versioninfo.json b/resources/versioninfo.json new file mode 100644 index 000000000..686dd014a --- /dev/null +++ b/resources/versioninfo.json @@ -0,0 +1,43 @@ +{ + "FixedFileInfo": { + "FileVersion": { + "Major": 0, + "Minor": 0, + "Patch": 0, + "Build": 0 + }, + "ProductVersion": { + "Major": 0, + "Minor": 0, + "Patch": 0, + "Build": 0 + }, + "FileFlagsMask": "3f", + "FileFlags ": "00", + "FileOS": "040004", + "FileType": "01", + "FileSubType": "00" + }, + "StringFileInfo": { + "Comments": "", + "CompanyName": "Storj Labs, Inc", + "FileDescription": "OVERWRITE", + "FileVersion": "", + "InternalName": "", + "LegalCopyright": "© Storj Labs, Inc", + "LegalTrademarks": "Storj is a trademark of Storj Labs Inc.\nTardigrade is a trademark of Storj Labs Inc.", + "OriginalFilename": "OVERWRITE", + "PrivateBuild": "OVERWRITE", + "ProductName": "Storj", + "ProductVersion": "OVERWRITE", + "SpecialBuild": "" + }, + "VarFileInfo": { + "Translation": { + "LangID": "0409", + "CharsetID": "04B0" + } + }, + "IconPath": "resources/icon.ico", + "ManifestPath": "" +}