diff --git a/Makefile b/Makefile index c4168cc..5864513 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,18 @@ PACKAGE=pluto -VERSION=1.4.1 +VERSION=`git describe --tags` +BUILD=`date +%FT%T%z` -ARCH_LINUX = $(PACKAGE)-$(VERSION)-linux-amd64 \ - $(PACKAGE)-$(VERSION)-linux-arm64 \ - $(PACKAGE)-$(VERSION)-linux-386 -ARCH_WIN = $(PACKAGE)-$(VERSION)-windows-amd64.exe \ - $(PACKAGE)-$(VERSION)-windows-386.exe +LDFLAGS=-ldflags "-w -s -X main.Version=${VERSION} -X main.Build=${BUILD}" -TARGET = $(PACKAGE)-$(VERSION)-linux-amd64 +ARCH_LINUX = $(PACKAGE)-linux-amd64 \ + $(PACKAGE)-linux-arm64 \ + $(PACKAGE)-linux-386 + +ARCH_WIN = $(PACKAGE)-windows-amd64.exe \ + $(PACKAGE)-windows-386.exe + +TARGET = $(PACKAGE)-linux-amd64 # TODO: Must write a configure.ac to find target for user end. # then we can use: @@ -23,30 +27,30 @@ dist: dist-linux dist-windows dist-windows: $(ARCH_WIN) dist-linux: $(ARCH_LINUX) -$(PACKAGE)-$(VERSION)-linux-arm64: +$(PACKAGE)-linux-arm64: GOOS=linux \ GOARCH=arm64 \ - go build -o=$@ + go build ${LDFLAGS} -o=$@ -$(PACKAGE)-$(VERSION)-linux-amd64: +$(PACKAGE)-linux-amd64: GOOS=linux \ GOARCH=amd64 \ - go build -o=$@ + go build ${LDFLAGS} -o=$@ -$(PACKAGE)-$(VERSION)-linux-386: +$(PACKAGE)-linux-386: GOOS=linux \ GOARCH=386 \ - go build -o=$@ + go build ${LDFLAGS} -o=$@ -$(PACKAGE)-$(VERSION)-windows-amd64.exe: +$(PACKAGE)-windows-amd64.exe: GOOS=windows \ GOARCH=amd64 \ - go build -o=$@ + go build ${LDFLAGS} -o=$@ -$(PACKAGE)-$(VERSION)-windows-386.exe: +$(PACKAGE)-windows-386.exe: GOOS=windows \ GOARCH=386 \ - go build -o=$@ + go build ${LDFLAGS} -o=$@ dist-clean: rm -f $(ARCH_WIN) $(ARCH_LINUX) diff --git a/pluto_cli.go b/pluto_cli.go index bf15139..b7bdb23 100644 --- a/pluto_cli.go +++ b/pluto_cli.go @@ -17,6 +17,9 @@ import ( "github.com/ishanjain28/pluto/pluto" ) +var Version string +var Build string + func main() { sig := make(chan os.Signal, 1) @@ -31,8 +34,17 @@ func main() { parts := flag.Uint("part", 32, "Number of Download parts") verbose := flag.Bool("verbose", false, "Enable Verbose Mode") name := flag.String("name", "", "Path or Name of save File") + version := flag.Bool("version", false, "Pluto Version") flag.Parse() + + if *version { + fmt.Println("Pluto - A Fast Multipart File Downloader") + fmt.Printf("Version: %s\n", Version) + fmt.Printf("Build: %s\n", Build) + return + } + urls := []string{} for i, v := range os.Args {