Skip to content

Commit d537274

Browse files
committed
Added documentation for the show command
1 parent b01fffc commit d537274

File tree

3 files changed

+80
-25
lines changed

3 files changed

+80
-25
lines changed

README.md

+18-11
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,19 @@ pip install --upgrade bump-my-version
4848

4949
Please find the changelog here: [CHANGELOG.md](CHANGELOG.md)
5050

51-
## Usage
51+
## Usage for version incrementing
5252

5353
> **NOTE:**
5454
>
5555
> Throughout this document, you can use `bumpversion` or `bump-my-version` interchangeably.
5656
57-
There are two modes of operation: On the command line for single-file operation and using a configuration file for more complex multi-file operations.
57+
There are two modes of operation: On the command line for single-file operation and using a configuration file (`pyproject.toml` or `.bumpversion.toml`) for more complex multi-file operations.
5858

59-
bump-my-version [options] part [file]
59+
> **WARNING:**
60+
>
61+
> The invocation of `bump-my-version` changed in version 0.6.0. It split functionality into sub-commands. It remains backward-compatible with previous versions. Previous usage is discouraged and may be removed in a 1.0 release.
62+
63+
bump-my-version bump [options] [part] [file]
6064

6165
### `part`
6266

@@ -68,7 +72,7 @@ Valid values include the named groups defined in the `parse` configuration.
6872

6973
Example bumping 0.5.1 to 0.6.0:
7074

71-
bump-my-version --current-version 0.5.1 minor
75+
bump-my-version bump --current-version 0.5.1 minor
7276

7377
### `file`
7478

@@ -81,7 +85,7 @@ These files are added to the list of files specified in your configuration file.
8185

8286
Example bumping 1.1.9 to 2.0.0:
8387

84-
bump-my-version --current-version 1.1.9 major setup.py
88+
bump-my-version bump --current-version 1.1.9 major setup.py
8589

8690
## Configuration file
8791

@@ -115,7 +119,7 @@ Similar to dry-run, but will also avoid checking the files. Also useful when you
115119
Print useful information to stderr. If specified more than once, it will output more information.
116120

117121
`--list`
118-
List machine-readable information to stdout for consumption by other programs.
122+
_DEPRECATED. Use `bump-my-version show` instead._ List machine-readable information to stdout for consumption by other programs.
119123

120124
Example output:
121125

@@ -127,19 +131,22 @@ Print help and exit
127131

128132
## Using bumpversion in a script
129133

130-
If you need to use the version generated by bumpversion in a script, you can make use of the `--list` option combined with `grep` and `sed`.
134+
If you need to use the version generated by bumpversion in a script, you can make use of the `show` subcommand.
131135

132136
Say, for example, that you are using git-flow to manage your project and want to automatically create a release. When you issue `git flow release start` you need to know the new version before applying the change.
133137

134138
The standard way to get it in a bash script is
135139

136-
bump-my-version --dry-run --list <part> | grep <field name> | sed -r s,"^.*=",,
140+
bump-my-version show new_version --increment <part>
137141

138-
where `part` is the part of the version number you are updating. You need to specify `--dry-run` to avoid bumpversion acting.
142+
where `part` is the part of the version number you are updating.
139143

140-
For example, if you are updating the minor number and looking for the new version number, this becomes
144+
For example, if you are updating the minor number and looking for the new version number, this becomes:
141145

142-
bump-my-version --dry-run --list minor | grep new_version | sed -r s,"^.*=",,
146+
```console
147+
$ bump-my-version show new_version --increment minor
148+
1.1.0
149+
```
143150

144151
## Development & Contributing
145152

docsrc/usage.md

+60-12
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,94 @@
55
Throughout this document, you can use `bumpversion` or `bump-my-version` interchangeably.
66
```
77

8-
There are two modes of operation: On the command line for single-file operation
9-
and using a configuration file (`pyproject.toml`) for more complex multi-file operations.
8+
There are two modes of operation: On the command line for single-file operation and using a configuration file (`pyproject.toml` or `.bumpversion.toml`) for more complex multi-file processes.
9+
10+
```{admonition} WARNING
11+
12+
The invocation of `bump-my-version` changed in version 0.6.0. It split functionality into sub-commands. It remains backward-compatible with previous versions. Previous usage is discouraged and may be removed in a 1.0 release.
13+
```
14+
## Incrementing a version
1015

1116
```console
12-
bump-my-version [OPTIONS] [VERSION_PART] [FILES]...
17+
bump-my-version bump [OPTIONS] [ARGS]...
1318
```
1419

15-
## `VERSION_PART`
20+
The `bump` sub-command triggers a version increment. The [complete list of options](cli.rst#bumpversion-bump) is available. The `ARGS` may contain a `VERSION_PART` or `FILES`
21+
22+
23+
### `VERSION_PART`
1624

1725
_**[optional]**_
1826

19-
The part of the version to increase, e.g. `minor`.
27+
The part of the version to increase, e.g., `minor`.
2028

21-
Valid values include those given in the `--serialize` / `--parse` option.
29+
Valid values include those given in the [`--serialize`](configuration.md#serialize) / [`--parse`](configuration.md#parse) option.
2230

2331
Example bumping 0.5.1 to 0.6.0:
2432

2533
```console
26-
bump-my-version --current-version 0.5.1 minor src/VERSION
34+
bump-my-version bump --current-version 0.5.1 minor src/VERSION
2735
```
2836

2937

30-
## `FILES`
38+
### `FILES`
3139

3240
_**[optional]**_<br />
3341
**default**: `None`
3442

3543
The additional file(s) to modify.
3644

37-
This file is added to the list of files specified in the configuration file. If you want to rewrite only files
38-
specified on the command line, use `--no-configured-files`.
45+
This file is added to the list of files specified in the configuration file. If you want to rewrite only files specified on the command line, use `--no-configured-files`.
3946

4047
Example bumping version 1.1.9 to 2.0.0 in the `setup.py` file:
4148

4249
```console
43-
bump-my-version --current-version 1.1.9 major setup.py
50+
bump-my-version bump --current-version 1.1.9 major setup.py
4451
```
4552

4653
Example bumping version 1.1.9 to 2.0.0 in _only_ the `setup.py` file:
4754

4855
```console
49-
bump-my-version --current-version 1.1.9 --no-configured-files major setup.py
56+
bump-my-version bump --current-version 1.1.9 --no-configured-files major setup.py
57+
```
58+
59+
## Showing configuration information
60+
61+
```console
62+
bump-my-version show [OPTIONS] [ARGS]
63+
```
64+
65+
The `show` subcommand allows you to output the entire or parts of the configuration to the console. The default invocation will output in the default format. The default format changes if one or more than one item is requested. If more than one item is asked for, it outputs the result of Python's `pprint` function. If only one thing is asked for, it outputs that value only.
66+
67+
```console
68+
$ bump-my-version show current_version
69+
1.0.0
70+
$ bump-my-version show current_version commit
71+
{'current_version': '1.0.0', 'commit': False}
72+
```
73+
74+
You can use the `--increment` option to enable a `new_version` key.
75+
76+
```console
77+
$ bump-my-version show --increment minor current_version new_version
78+
{'current_version': '1.0.0', 'new_version': '1.1.0'}
79+
```
80+
81+
You can also specify the output to be in JSON or YAML format:
82+
83+
```console
84+
$ bump-my-version show --format yaml current_version
85+
current_version: "1.0.0"
86+
$ bump-my-version show --format yaml current_version commit
87+
current_version: "1.0.0"
88+
commit: false
89+
$ bump-my-version show --format json current_version
90+
{
91+
"current_version": "1.0.0"
92+
}
93+
$ bump-my-version show --format json current_version commit
94+
{
95+
"current_version": "1.0.0",
96+
"commit": false,
97+
}
5098
```

docsrc/version-parts.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ The `serialize` configuration value is a list of default formats. You have the o
2020

2121
```toml
2222
serialize = [
23-
"{major}.{minor}.{patch}",
24-
"{major}.{minor}",
23+
"{major}.{minor}.{patch}",
24+
"{major}.{minor}",
2525
]
2626
```
2727

0 commit comments

Comments
 (0)