Skip to content

Commit 13f0bbc

Browse files
author
Sylvain Viart
committed
commit for v0.6.3-rc1 tag #32
* get_docopts.sh now handle new binaries naming from gox compile with deploy.sh * docopts.go now support linker variable for Version and use govvv * updated Makefile and deploy.sh to use govvv * README.md documentation updated about version 0.6.3-rc1
1 parent 5bd515e commit 13f0bbc

File tree

13 files changed

+360
-177
lines changed

13 files changed

+360
-177
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
docopts
2-
docopts-*
32
*.swp
43
env
4+
build/docopts_*
5+
build/docopts.go

Makefile

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,47 @@
33
#
44
# See also: deploy.sh
55

6-
76
PREFIX ?= /usr/local
87

8+
# dependancies
9+
GOVVV=${GOPATH}/bin/govvv
10+
DOCTOP_LIB=${GOPATH}/src/github.com/docopt/docopt-go/docopt.go
11+
912
# keep this as first target for development
1013
# build 64 bits version
11-
docopts: docopts.go
12-
go build docopts.go
14+
docopts: docopts.go Makefile ${GOVVV} ${DOCTOP_LIB}
15+
# ldflags need to be synchronised with deploy.sh
16+
go build -ldflags "$$(govvv -flags) -X 'main.GoBuildVersion=$$(go version)'" docopts.go
17+
18+
install_builddep: ${GOVVV} ${DOCTOP_LIB}
19+
go get github.com/mitchellh/gox
20+
go get github.com/itchio/gothub
21+
go get gopkg.in/mikefarah/yq.v2
1322

14-
docopt-go:
23+
${DOCTOP_LIB}:
1524
go get github.com/docopt/docopt-go
1625

17-
all: docopt-go docopts docopts-arm docopts-32bits docopts-OSX README.md
26+
${GOVVV}:
27+
go get github.com/ahmetb/govvv
1828

19-
# build 32 bits version too
20-
docopts-32bits: docopts.go
21-
env GOOS=linux GOARCH=386 go build -o docopts-32bits docopts.go
29+
all: install_builddep docopts README.md
30+
./deploy.sh build current
2231

23-
# build for OSX
24-
docopts-OSX: docopts.go
25-
env GOOS=darwin go build -o docopts-OSX docopts.go
32+
############################ cross compile, we use gox now inside deploy.sh
33+
34+
## build 32 bits version too
35+
#docopts-32bits: docopts.go
36+
# env GOOS=linux GOARCH=386 go build -o docopts-32bits docopts.go
37+
#
38+
## build for OSX
39+
#docopts-OSX: docopts.go
40+
# env GOOS=darwin go build -o docopts-OSX docopts.go
41+
#
42+
## build 32 bits version too
43+
#docopts-arm: docopts.go
44+
# env GOOS=linux GOARCH=arm go build -o docopts-arm docopts.go
2645

27-
# build 32 bits version too
28-
docopts-arm: docopts.go
29-
env GOOS=linux GOARCH=arm go build -o docopts-arm docopts.go
46+
###########################
3047

3148
# requires write access to $PREFIX
3249
install: all

README.md

Lines changed: 38 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[docopt](http://docopt.org/) for shell - make beautiful CLI with ease.
44

5-
Status: Alpha - work is done.
5+
Status: working.
66

77
`docopts` : the command line wrapper for bash.
88

@@ -14,10 +14,10 @@ GNU/Linux OS.
1414
[make README.md]: # (./docopts --version | get_version "This is a transitional release:")
1515

1616
```
17-
This is a transitional release: docopts 0.6.3
17+
This is a transitional release: v0.6.3-rc1
1818
```
1919

20-
This release will be maintained for compatibility, only fixes will be provided. The 0.6.2 version is fully compatible with
20+
This release will be maintained for compatibility, only fixes will be provided. The 0.6.3 version is fully compatible with
2121
the previous version of `docopts`.
2222

2323
## SYNOPSIS
@@ -286,24 +286,37 @@ cp docopts docopts.sh /usr/local/bin
286286

287287
### Pre-built binaries
288288

289-
Pre-built Go binaries for GNU/Linux (32 and 64 bits) are attached to [releases](https://github.com/Sylvain303/docopts/releases).
289+
Pre-built Go binaries for GNU/Linux (32 and 64 bits) are attached to [releases](https://github.com/docopt/docopts/releases).
290290

291-
Download and rename to `docopts` and put it in your `PATH`:
291+
We provide a download helper:
292292

293+
```bash
294+
git clone https://github.com/docopt/docopts.git
295+
cd doctops
296+
./get_docopts.sh
293297
```
294-
mv docopts-32bit docopts
298+
299+
Rename to `docopts` and put it in your `PATH`:
300+
301+
```bash
302+
mv docopts_linux_amd64 docopts
295303
cp docopts docopts.sh /usr/local/bin
296304
```
297305

298-
You are strongly encouraged to build your own binary, which is easy once
299-
you have Go installed. Or find a local golang developer that you
300-
trust and ask her, in exchange for a beer or two, if she could build it for you. ;)
306+
The cloned repository is no more used at this stage.
307+
308+
Learn more about [pre-built binaries](docs/pre_built_binaries.md).
301309

302310
## Compiling
303311

304-
Requires a directory to use as a [Go workspace](https://golang.org/doc/code.html#Organization).
312+
We encourage you to build your own binary, which is easy once
313+
you have Go installed. Or find a local golang developer that you
314+
trust and ask her, in exchange for a beer or two, if she could build it for you. ;)
315+
316+
Requires a [Go workspace](https://golang.org/doc/code.html#Organization).
305317

306318
local build:
319+
(also done with our Makefile default target: `make`)
307320

308321
```
309322
go get github.com/docopt/docopt-go
@@ -318,119 +331,39 @@ cross compile for 32 bit:
318331
env GOOS=linux GOARCH=386 go build docopts.go
319332
```
320333

321-
or via Makefile (generates 64 bit, 32 bit, arm and macOS-64bit versions of docopts)
334+
or via Makefile:
322335

323336
```
324337
cd src/github.com/docopt/docopts
325338
make all
326339
make test
327340
```
328341

329-
Tested builds are built on: `go version go1.11.4 linux/amd64`
342+
Tested builds are built on:
343+
344+
[make README.md]: # (go version)
345+
346+
```
347+
go version go1.11.4 linux/amd64
348+
```
330349

331350
## Features
332351

333352
Warning: may be not up-to-date feature list.
334353

335354
The [`docopts.sh`](docopts.sh) helper is an extra bash library that you can source in your shell script.
336-
This library provides some bash helpers and is not required in order to use `docopts`.
355+
This library provides some bash helpers and is not required in order to use `docopts`. See [docopts.sh
356+
documentation](docs/README.md).
337357

338-
You don't need a python interpreter anymore, so it works on any legacy system.
358+
`docopts` doesn't need a python interpreter anymore, so it works on any legacy system too.
339359

340360
As of 2019-05-18
341361

342362
* `docopts` is able to reproduce 100% of the python version.
343-
* unit tests for go are provided, so hack as you wish.
344-
* 100% of `language_agnostic_tester.py` tests pass (GNU/Linux 64bits)
363+
* unit tests for Go are provided, so hack as you wish.
364+
* 100% of `language_agnostic_tester.py` tests pass (GNU/Linux 64bits).
365+
* `bats-core` unittests and fonctional testing are provided too.
345366

346367
## Developers
347368

348-
All python related stuff has been removed, excepted `language_agnostic_tester.py`.
349-
350-
If you want to clone this repository and hack `docopts`:
351-
352-
Use `git clone --recursive`, to get submodules - these are only required for testing with `bats`.
353-
If [`bats-core`](https://github.com/bats-core/bats-core) installed in your PATH should work too.
354-
355-
Fetch the extra golang version of `docopt-go` (required for building `docopts`)
356-
357-
```
358-
go get github.com/docopt/docopt-go
359-
```
360-
361-
If you forgot `--recursive`, you can also run it afterwards:
362-
363-
~~~bash
364-
git submodule init
365-
git submodule update
366-
~~~
367-
368-
Current folder structure:
369-
370-
~~~
371-
.
372-
├── docopts.go - main source code
373-
├── docopts_test.go - go unit tests
374-
├── docopts.sh - library wrapper and helpers
375-
├── examples - many ported examples in bash, all must be working
376-
├── language_agnostic_tester.py - old python JSON tester still used with testee.sh
377-
├── LICENSE-MIT
378-
├── PROGRESS.md - what I'm working on
379-
├── README.md
380-
├── testcases.docopt - agnostic testcases copied from python's docopt
381-
├── testee.sh - bash wrapper to convert docopts output to JSON (now uses docopts.sh)
382-
├── tests - unit and functional testing written in bats (requires submodule)
383-
└── TODO.md - Some todo list on this golang version of docopts
384-
~~~
385-
386-
## Tests
387-
388-
Some tests are coded along with this code base:
389-
390-
- bats - bash unit tests and functional testing.
391-
- `language_agnostic_tester.py` - old python wrapper, full docopt compatibility tests.
392-
- See also: [docopt.go](https://github.com/docopt/docopt.go) has its own tests in golang.
393-
- `docopts_test.go` - go unit test for `docopts.go`
394-
395-
### Running tests
396-
397-
```
398-
make test
399-
```
400-
401-
#### bats
402-
403-
`bats.alias` modify your current environment to define a alias on the submodule of `bats` installed (if you did it).
404-
405-
```
406-
cd ./tests
407-
. bats.alias
408-
bats .
409-
```
410-
411-
#### `language_agnostic_tester`
412-
413-
This script was provided with the original `docopts`. I fixed number/string output parsing failure with an extra function
414-
for bash in [docopts.sh](https://github.com/docopt/docopts/blob/docopts-go/docopts.sh#L108)
415-
`docopt_get_raw_value()`. This is a hack to get 100% pass, and it is not very efficient.
416-
417-
Run these tests from top of repo:
418-
```
419-
python language_agnostic_tester.py ./testee.sh
420-
```
421-
422-
#### golang docopt.go (golang parser lib)
423-
424-
This lib is outside this project, but it is the base of the `docopt` language parsing for this wrapper.
425-
426-
```
427-
cd PATH/to/go/src/github.com/docopt/docopt-go/
428-
go test -v .
429-
```
430-
431-
#### golang docopts (our bash wrapper)
432-
433-
```
434-
cd PATH/to/go/src/github.com/docopt/docopts
435-
go test -v
436-
```
369+
Read the [doc for developer](docs/developer.md).

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v0.6.3-rc1

build/.placeholder

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
build directory
2+
3+
WARNING: make clean will remove everthing in that directory!

build_doc.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,10 @@ get_usage() {
183183
sed -n '/^Usage:/,/^$/ p' | sed -e '1d' -e '$d'
184184
}
185185

186-
# extract text bloc starting at Usage to the first blank line.
187-
# remove Usage and blank line.
186+
# extract docopts version
188187
get_version() {
189188
local text="$1"
190-
local version=$(head -1)
189+
local version=$(awk 'NR == 1 { print $2 }')
191190
echo "$text $version"
192191
}
193192

0 commit comments

Comments
 (0)