|
| 1 | +# The show subcommand |
| 2 | + |
| 3 | +The main purpose of the `show` subcommand is to provide access to configuration data via scripts. |
| 4 | + |
| 5 | +## Basic use |
| 6 | + |
| 7 | +The configuration object is a `dict` containing nested data structures. The arguments and options of this command relate to extracting data from the configuration object and presenting the extracted data. |
| 8 | + |
| 9 | +## Specifying the output data |
| 10 | + |
| 11 | +The positional arguments determine the data shown. If nothing or `all` is passed, the entire configuration is shown. |
| 12 | + |
| 13 | +Positional arguments are specified using a format like [Django variable resolution](https://docs.djangoproject.com/en/5.0/ref/templates/language/#variables). |
| 14 | + |
| 15 | +Examples: |
| 16 | + |
| 17 | +- `a.b` specifies the "b" key in the nested dictionaries: `{"a": {"b": "value"}}` |
| 18 | +- `a.3` specifies the 4th item (the first is 0) of the list at key "a": `{"a": ["no", "nay", "nyet", "value"]}` |
| 19 | + |
| 20 | +## Specifying the output format |
| 21 | + |
| 22 | +If only one positional argument is passed, the default format only shows its value. If no positional arguments, several positional arguments, or `all` is passed, the output from [`pprint.pprint`](https://docs.python.org/3.12/library/pprint.html#pprint.pprint) is shown. |
| 23 | + |
| 24 | +This makes getting the current version easy: |
| 25 | + |
| 26 | +```console |
| 27 | +$ bump-my-version show current_version |
| 28 | +1.0.1 |
| 29 | +``` |
| 30 | + |
| 31 | +You can request the output be formatted as YAML or JSON: |
| 32 | + |
| 33 | +```console |
| 34 | +$ bump-my-version show --format yaml current_version |
| 35 | +current_version: "1.0.1" |
| 36 | +$ bump-my-version show --format json current_version |
| 37 | +{ |
| 38 | + "current_version": "1.0.1" |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +## Including the incremented version before bumping |
| 43 | + |
| 44 | +Your workflow might want to know the new version before you actually do the bumping. The `--increment` or `-i` option accepts a version part to bump and adds a `new_version` key into the configuration. |
| 45 | + |
| 46 | +```console |
| 47 | +$ bump-my-version --increment patch show |
| 48 | +1.0.2 |
| 49 | +$ bump-my-version --increment minor show |
| 50 | +1.1.0 |
| 51 | +$ bump-my-version --increment major show |
| 52 | +2.0.0 |
| 53 | +``` |
0 commit comments