Skip to content

Commit 28f7622

Browse files
authored
Support: Copy usage screen to README (#16)
1 parent ab15022 commit 28f7622

3 files changed

Lines changed: 124 additions & 49 deletions

File tree

README.md

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Build Status](https://travis-ci.com/chriskilding/semver.svg?branch=master)](https://travis-ci.com/chriskilding/semver)
44
[![Codecov](https://codecov.io/gh/chriskilding/semver/branch/master/graph/badge.svg)](https://codecov.io/gh/chriskilding/semver)
55

6-
Semantic Version utility.
6+
Semantic Versioning utility.
77

88
## Overview
99

@@ -18,8 +18,8 @@ Valid examples:
1818
- `0.0.0`
1919
- `1.0.0`
2020
- `1.2.3-alpha`
21-
- `1.2.3+20080101`
22-
- `1.2.3-alpha+20080101`
21+
- `1.2.3+2008`
22+
- `1.2.3-alpha+2008`
2323

2424
Invalid examples:
2525

@@ -30,28 +30,54 @@ The `semver` utility compares, generates, modifies, parses, sorts, and validates
3030

3131
## Usage
3232

33-
Read the help screen for instructions.
33+
Read the help screen for reference:
3434

35-
semver --help
36-
37-
Read the man page for full instructions and examples.
35+
```bash
36+
$ semver --help
37+
```
38+
39+
Usage:
40+
semver compare <version> <version>
41+
semver decrement-major <version>
42+
semver decrement-minor <version>
43+
semver decrement-patch <version>
44+
semver get-major <version>
45+
semver get-minor <version>
46+
semver get-patch <version>
47+
semver get-prerelease <version>
48+
semver get-build <version>
49+
semver grep -
50+
semver increment-major <version>
51+
semver increment-minor <version>
52+
semver increment-patch <version>
53+
semver init
54+
semver sort -
55+
semver validate <string>
56+
semver (-h | --help)
57+
58+
Options:
59+
-h --help Show this help screen.
60+
61+
Read the man page for full instructions and examples:
3862

39-
man semver
63+
```bash
64+
$ man semver
65+
```
4066

4167
## Dependencies
4268

4369
- [Perl](http://www.perl.org) 5+ (pre-installed on: macOS, Debian, openSUSE)
4470
- [Bats](https://github.com/bats-core/bats-core) (test)
45-
- [Shellcheck](https://github.com/koalaman/shellcheck) (test)
4671

4772
## Install
4873

49-
1. Download the `semver` script from the repository somehow.
50-
2. Place it anywhere on your `$PATH`.
74+
```bash
75+
$ make install
76+
```
5177

5278
## Test
5379

5480
```bash
55-
make test
81+
$ make test
5682
```
5783

semver

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ sub usage() {
4040
say STDERR " $program (-h | --help)";
4141
say STDERR "";
4242
say STDERR "Options:";
43-
say STDERR " -h --help Show this screen.";
43+
say STDERR " -h --help Show this help screen.";
4444

4545
exit 1;
4646
}

semver.1

Lines changed: 85 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -92,99 +92,131 @@ are omitted, no result will be printed, and the utility will exit with an error
9292
Note: Precedence comparison is NOT a simple lexicographic or numerical comparison - for details please read the Semver.org specification linked at the end of this document.
9393
.Ss decrement-major
9494
.Nm
95-
can decrement the MAJOR component of a Semantic Version
95+
can decrement the MAJOR component of a
9696
.Ar version
97-
\&.
97+
string.
9898
.Pp
9999
The MINOR, PATCH, PRERELEASE, and BUILD components will be reset when a decrement occurs.
100100
.Pp
101101
The formula is:
102102
.Dl MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD] -> (MAJOR - 1).0.0
103103
.Pp
104+
The operation will fail:
105+
.Bl -bullet -compact
106+
.It
104107
If the MAJOR component of
105108
.Ar version
106-
is 0, the decrement operation will halt, and the utility will exit with an error code.
109+
is already 0.
110+
.It
111+
If
112+
.Ar version
113+
is invalid.
114+
.El
107115
.Ss decrement-minor
108116
.Nm
109-
can decrement the MINOR component of a Semantic Version
117+
can decrement the MINOR component of a
110118
.Ar version
111-
\&.
119+
string.
112120
.Pp
113121
The PATCH, PRERELEASE, and BUILD components will be reset when a decrement occurs.
114122
.Pp
115123
The formula is:
116124
.Dl MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD] -> MAJOR.(MINOR - 1).0
117125
.Pp
126+
The operation will fail:
127+
.Bl -bullet -compact
128+
.It
118129
If the MINOR component of
119130
.Ar version
120-
is 0, the decrement operation will halt, and the utility will exit with an error code.
131+
is already 0.
132+
.It
133+
If
134+
.Ar version
135+
is invalid.
136+
.El
121137
.Ss decrement-patch
122138
.Nm
123-
can decrement the PATCH component of a Semantic Version
139+
can decrement the PATCH component of a
124140
.Ar version
125-
\&.
141+
string.
126142
.Pp
127143
The PRERELEASE and BUILD components will be reset when a decrement occurs.
128144
.Pp
129145
The formula is:
130146
.Dl MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD] -> MAJOR.MINOR.(PATCH - 1)
131147
.Pp
148+
The operation will fail:
149+
.Bl -bullet -compact
150+
.It
132151
If the PATCH component of
133152
.Ar version
134-
is 0, the decrement operation will halt, and the utility will exit with an error code.
153+
is already 0.
154+
.It
155+
If
156+
.Ar version
157+
is invalid.
158+
.El
135159
.Ss get-major
136160
.Nm
137-
can get the MAJOR component of a Semantic Version
161+
can get the MAJOR component of a
138162
.Ar version
139-
\&.
163+
string.
140164
.Pp
141-
If
165+
The operation will fail if
142166
.Ar version
143-
is invalid, nothing will be printed, and the utility will exit with an error code.
167+
is invalid.
144168
.Ss get-minor
145169
.Nm
146-
can get the MINOR component of a Semantic Version
170+
can get the MINOR component of a
147171
.Ar version
148-
\&.
172+
string.
149173
.Pp
150174
If
151175
.Ar version
152176
is invalid, nothing will be printed, and the utility will exit with an error code.
153177
.Ss get-patch
154178
.Nm
155-
can get the PATCH component of a Semantic Version
179+
can get the PATCH component of a
156180
.Ar version
157-
\&.
181+
string.
158182
.Pp
159-
If
183+
The operation will fail if
160184
.Ar version
161-
is invalid, nothing will be printed, and the utility will exit with an error code.
185+
is invalid.
162186
.Ss get-prerelease
163187
.Nm
164-
can get the PRERELEASE component of a Semantic Version
188+
can get the PRERELEASE component of a
165189
.Ar version
166-
\&.
190+
string.
167191
.Pp
192+
The operation will fail:
193+
.Bl -bullet -compact
194+
.It
168195
If
169196
.Ar version
170-
does not contain a PRERELEASE, nothing will be printed, and the utility will exit with an error code.
171-
.Pp
172-
If
197+
does not contain a PRERELEASE.
198+
.It
199+
If
173200
.Ar version
174-
is invalid, nothing will be printed, and the utility will exit with an error code.
201+
is invalid.
202+
.El
175203
.Ss get-build
176204
.Nm
177-
can get the BUILD component of a Semantic Version
205+
can get the BUILD component of a
178206
.Ar version
179-
\&.
207+
string.
180208
.Pp
209+
The operation will fail:
210+
.Bl -bullet -compact
211+
.It
181212
If
182213
.Ar version
183-
does not contain a BUILD, nothing will be printed, and the utility will exit with an error code.
184-
.Pp
185-
If
214+
does not contain a BUILD.
215+
.It
216+
If
186217
.Ar version
187-
is invalid, nothing will be printed, and the utility will exit with an error code.
218+
is invalid.
219+
.El
188220
.Ss grep
189221
.Nm
190222
can parse text from STDIN to extract zero or more Semantic Version strings, in the style of
@@ -194,7 +226,6 @@ can parse text from STDIN to extract zero or more Semantic Version strings, in t
194226
A candidate version
195227
.Sq string
196228
will be matched within the text stream if it meets the following criteria:
197-
.Pp
198229
.Bl -bullet -compact
199230
.It
200231
.Sq string
@@ -211,31 +242,49 @@ has whitespace immediately after it, OR its last character is also the last char
211242
.El
212243
.Ss increment-major
213244
.Nm
214-
can increment the MAJOR version of a Semantic Version string.
245+
can increment the MAJOR component of a
246+
.Ar version
247+
string.
215248
.Pp
216249
The MINOR, PATCH, PRERELEASE, and BUILD components will be reset when an increment occurs.
217250
.Pp
218251
The formula is:
219252
.Dl MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD] -> (MAJOR + 1).0.0
253+
.Pp
254+
The operation will fail if
255+
.Ar version
256+
is invalid.
220257
.Ss increment-minor
221258
.Nm
222-
can increment the MINOR version of a Semantic Version string.
259+
can increment the MINOR component of a
260+
.Ar version
261+
string.
223262
.Pp
224263
The PATCH, PRERELEASE, and BUILD components will be reset when an increment occurs.
225264
.Pp
226265
The formula is:
227266
.Dl MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD] -> MAJOR.(MINOR + 1).0
267+
.Pp
268+
The operation will fail if
269+
.Ar version
270+
is invalid.
228271
.Ss increment-patch
229272
.Nm
230-
can increment the PATCH version of a Semantic Version string.
273+
can increment the PATCH component of a
274+
.Ar version
275+
string.
231276
.Pp
232277
The PRERELEASE and BUILD components will be reset when an increment occurs.
233278
.Pp
234279
The formula is:
235280
.Dl MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD] -> MAJOR.MINOR.(PATCH + 1)
281+
.Pp
282+
The operation will fail if
283+
.Ar version
284+
is invalid.
236285
.Ss init
237286
.Nm
238-
can print the minimum acceptable Semantic Version
287+
can print the minimum Semantic Version
239288
.Sq 0.0.0
240289
to STDOUT. You can use this as a base-case initializer, for example in a script which fails to find any Semantic Versions in its input.
241290
.Ss sort

0 commit comments

Comments
 (0)