Skip to content
This repository was archived by the owner on Jul 14, 2022. It is now read-only.

Commit d8b54f6

Browse files
authored
✨Makefile and setting version by tag (#11)
* 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
1 parent 4e31879 commit d8b54f6

File tree

4 files changed

+85
-16
lines changed

4 files changed

+85
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*.dll
1010
*.so
1111
*.dylib
12+
pwcli
1213

1314
# Test binary, built with `go test -c`
1415
*.test

Makefile

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
PREFIX?=/usr/local
2+
BINDIR?=$(PREFIX)/bin
3+
VERSION?=$(shell git tag | grep ^v | sort -V | tail -n 1)
4+
GOFLAGS?=-ldflags '-X main.VERSION=${VERSION}'
5+
6+
pwcli: cli.go go.mod go.sum
7+
@echo
8+
@echo Building pwcli. This may take a minute or two.
9+
@echo
10+
go build $(GOFLAGS) -o $@
11+
@echo
12+
@echo ...Done\!
13+
14+
.PHONY: clean
15+
clean:
16+
@echo
17+
@echo Cleaning...
18+
@echo
19+
go clean
20+
@echo
21+
@echo ...Done\!
22+
23+
.PHONY: update
24+
update:
25+
@echo
26+
@echo Updating from upstream repository...
27+
@echo
28+
git pull --rebase origin master
29+
@echo
30+
@echo ...Done\!
31+
32+
.PHONY: install
33+
install:
34+
@echo
35+
@echo Installing pwcli...
36+
@echo
37+
install -m755 pwcli $(BINDIR)
38+
@echo
39+
@echo ...Done\!
40+
41+
.PHONY: uninstall
42+
uninstall:
43+
@echo
44+
@echo Uninstalling pwcli...
45+
@echo
46+
rm -f $(BINDIR)/pwcli
47+
@echo
48+
@echo ...Done\!

README.md

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,41 @@
1-
# 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)
1+
# 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)
2+
23
Use Postwoman's CLI direct from your terminal.
34

45
# Installation
6+
57
### From Script
8+
69
```bash
710
$ sh -c "$(curl -sL https://git.io/getpwcli)"
811
```
12+
913
### From Source
14+
1015
- Clone the repo
11-
- Build using `go build`
12-
- Move Binary to `/usr/local/bin/`
16+
17+
```
18+
$ git clone https://github.com/athul/pwcli
19+
```
20+
21+
- Build and install
22+
23+
```
24+
$ make
25+
26+
$ sudo make install
27+
```
28+
1329
### From Binary
14-
- You can find the Binaries in Gzipped form from the [Releases](https://github.com/athul/pwcli/releases) page
15-
**Supports**
30+
31+
- You can find the Binaries in Gzipped form from the [Releases](https://github.com/athul/pwcli/releases) page
32+
**Supports**
1633
- Linux(x64,x86)
1734
- Mac(x64)
1835
- Windows(x64,x86)
1936

2037
### Homebrew
38+
2139
Install by `brew install athul/tap/pwcli`
2240

2341
> **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`
2644

2745
Putting Simply: **Just pass the URL to the request method**
2846

29-
3047
- GET : `pwcli get <url> -t/--token <token> -u <username for basic auth> -p <password for basic auth>`
3148
- POST: `pwcli post <url> < -t/-u/-p > -c/--content type <content type> -b/--body <body>`
3249
- PATCH: `pwcli patch <url> < -t/-u/-p > -c/--content type <content type> -b/--body <body>`
3350
- PUT : `pwcli put <url> < -t/-u/-p > -c/--content type <content type> -b/--body <body>`
3451
- DELETE: `pwcli delete <url> < -t/-u/-p > -c/--content type <content type> -b/--body <body>`
3552

36-
**Content Types can be of**
37-
`html` : `text/html`
38-
`js` : `application/json`,
39-
`xml` : `application/xml`
40-
`plain` : `text/plain`,
41-
53+
**Content Types can be of**
54+
`html` : `text/html`
55+
`js` : `application/json`,
56+
`xml` : `application/xml`
57+
`plain` : `text/plain`,
4258

4359
#### Extra
44-
**SEND**: This can be used to test multiple endpoints from the `postwoman-collection.json` file. The output will only be the `statuscode`.
45-
RUN: `pwcli send <PATH to postwoman collection.json>`
46-
OUTPUT:
60+
61+
**SEND**: This can be used to test multiple endpoints from the `postwoman-collection.json` file. The output will only be the `statuscode`.
62+
RUN: `pwcli send <PATH to postwoman collection.json>`
63+
OUTPUT:
4764
![](/assets/send.png)

cli.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ import (
1010
"github.com/urfave/cli"
1111
)
1212

13+
// VERSION is set by `make` during the build to the most recent tag
14+
var VERSION = "v0.0.4"
15+
1316
func main() {
1417
app := cli.NewApp()
1518
app.Name = color.HiGreenString("Postwoman CLI")
16-
app.Version = color.HiRedString("0.0.2")
19+
app.Version = color.HiRedString(VERSION)
1720
app.Usage = color.HiYellowString("Test API endpoints without the hassle")
1821
app.Description = color.HiBlueString("Made with <3 by Postwoman Team")
1922

0 commit comments

Comments
 (0)