From d8b54f69c50d25dc33579eda5dd303cc8e1799c9 Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Fri, 14 Feb 2020 15:35:33 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Makefile=20and=20setting=20version=20b?= =?UTF-8?q?y=20tag=20(#11)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ignoring binary * makefile to aid in install/uninstall, and to set the version in cli.go at build time * install instructions using make * oopsed the destination directory in the Makefile --- .gitignore | 1 + Makefile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 47 ++++++++++++++++++++++++++++++++--------------- cli.go | 5 ++++- 4 files changed, 85 insertions(+), 16 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index baf40be..5804758 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ *.dll *.so *.dylib +pwcli # Test binary, built with `go test -c` *.test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b587845 --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +PREFIX?=/usr/local +BINDIR?=$(PREFIX)/bin +VERSION?=$(shell git tag | grep ^v | sort -V | tail -n 1) +GOFLAGS?=-ldflags '-X main.VERSION=${VERSION}' + +pwcli: cli.go go.mod go.sum + @echo + @echo Building pwcli. This may take a minute or two. + @echo + go build $(GOFLAGS) -o $@ + @echo + @echo ...Done\! + +.PHONY: clean +clean: + @echo + @echo Cleaning... + @echo + go clean + @echo + @echo ...Done\! + +.PHONY: update +update: + @echo + @echo Updating from upstream repository... + @echo + git pull --rebase origin master + @echo + @echo ...Done\! + +.PHONY: install +install: + @echo + @echo Installing pwcli... + @echo + install -m755 pwcli $(BINDIR) + @echo + @echo ...Done\! + +.PHONY: uninstall +uninstall: + @echo + @echo Uninstalling pwcli... + @echo + rm -f $(BINDIR)/pwcli + @echo + @echo ...Done\! diff --git a/README.md b/README.md index f57f901..c900b8a 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,41 @@ -# PostWoman CLI [![Build Status](https://travis-ci.com/athul/pwcli.svg?token=udLtq6DyJs4Gxpze9nqX&branch=master)](https://travis-ci.com/athul/pwcli)[![Postwoman](https://img.shields.io/badge/Made_for-Postwoman-hex_color_code?logo=Postwoman)](https://postwoman.io) [![Go Report Card](https://goreportcard.com/badge/github.com/athul/pwcli)](https://goreportcard.com/report/github.com/athul/pwcli) +# PostWoman CLI [![Build Status](https://travis-ci.com/athul/pwcli.svg?token=udLtq6DyJs4Gxpze9nqX&branch=master)](https://travis-ci.com/athul/pwcli) [![Postwoman](https://img.shields.io/badge/Made_for-Postwoman-hex_color_code?logo=Postwoman)](https://postwoman.io) [![Go Report Card](https://goreportcard.com/badge/github.com/athul/pwcli)](https://goreportcard.com/report/github.com/athul/pwcli) + Use Postwoman's CLI direct from your terminal. # Installation + ### From Script + ```bash $ sh -c "$(curl -sL https://git.io/getpwcli)" ``` + ### From Source + - Clone the repo -- Build using `go build` -- Move Binary to `/usr/local/bin/` + +``` +$ git clone https://github.com/athul/pwcli +``` + +- Build and install + +``` +$ make + +$ sudo make install +``` + ### From Binary -- You can find the Binaries in Gzipped form from the [Releases](https://github.com/athul/pwcli/releases) page -**Supports** + +- You can find the Binaries in Gzipped form from the [Releases](https://github.com/athul/pwcli/releases) page + **Supports** - Linux(x64,x86) - Mac(x64) - Windows(x64,x86) ### Homebrew + Install by `brew install athul/tap/pwcli` > **IMPORTANT: Not tested on Windows, please leave your feedback/bugs in the Issues section** @@ -26,22 +44,21 @@ Install by `brew install athul/tap/pwcli` Putting Simply: **Just pass the URL to the request method** - - GET : `pwcli get -t/--token -u -p ` - POST: `pwcli post < -t/-u/-p > -c/--content type -b/--body ` - PATCH: `pwcli patch < -t/-u/-p > -c/--content type -b/--body ` - PUT : `pwcli put < -t/-u/-p > -c/--content type -b/--body ` - DELETE: `pwcli delete < -t/-u/-p > -c/--content type -b/--body ` -**Content Types can be of** -`html` : `text/html` -`js` : `application/json`, -`xml` : `application/xml` -`plain` : `text/plain`, - +**Content Types can be of** +`html` : `text/html` +`js` : `application/json`, +`xml` : `application/xml` +`plain` : `text/plain`, #### Extra -**SEND**: This can be used to test multiple endpoints from the `postwoman-collection.json` file. The output will only be the `statuscode`. -RUN: `pwcli send ` -OUTPUT: + +**SEND**: This can be used to test multiple endpoints from the `postwoman-collection.json` file. The output will only be the `statuscode`. +RUN: `pwcli send ` +OUTPUT: ![](/assets/send.png) diff --git a/cli.go b/cli.go index 550d1c7..3db2480 100644 --- a/cli.go +++ b/cli.go @@ -10,10 +10,13 @@ import ( "github.com/urfave/cli" ) +// VERSION is set by `make` during the build to the most recent tag +var VERSION = "v0.0.4" + func main() { app := cli.NewApp() app.Name = color.HiGreenString("Postwoman CLI") - app.Version = color.HiRedString("0.0.2") + app.Version = color.HiRedString(VERSION) app.Usage = color.HiYellowString("Test API endpoints without the hassle") app.Description = color.HiBlueString("Made with <3 by Postwoman Team")