|
| 1 | +# Changelog parser |
| 2 | + |
| 3 | +A command-line tool to easily manage and manipulate changelog files, ensuring consistency with the [keep a changelog](https://keepachangelog.com) format. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Format and parse: Validate and automatically format your changelog file. |
| 8 | +- Initialize a new changelog file: Quickly set up a standardized changelog for your project. |
| 9 | +- Add a new change to a release: Easily add a new change to your changelog. |
| 10 | +- Add a new release: Cut a new release in your changelog. |
| 11 | +- List all releases: Get a list of all releases in your changelog. |
| 12 | +- Show all changes in a release: Display all changes in a specific release. |
| 13 | +- Merge two or more changelog files: Combine multiple changelog files into one. |
| 14 | + |
| 15 | +## Usage |
| 16 | + |
| 17 | +Default parameters use the `CHANGELOG.md` file in the current directory, this can be changed with the `-f` flag. |
| 18 | + |
| 19 | +### Format and parse |
| 20 | + |
| 21 | +The `fmt` command parses and formats the changelog file to adhere to the keep a changelog format. |
| 22 | + |
| 23 | +```shell |
| 24 | +changelog-parser fmt |
| 25 | +``` |
| 26 | + |
| 27 | +This command exits with a non-zero status code if the changelog format is invalid. |
| 28 | + |
| 29 | +```shell |
| 30 | +changelog-parser fmt --silent || echo "Invalid changelog format" |
| 31 | +``` |
| 32 | + |
| 33 | +Changes can be written back to the file with the `--write` flag. |
| 34 | + |
| 35 | +### Initialize a new changelog file |
| 36 | + |
| 37 | +The `init` command initializes a new changelog file. |
| 38 | + |
| 39 | +```shell |
| 40 | +changelog-parser init |
| 41 | +``` |
| 42 | + |
| 43 | +This command creates a new changelog file with the following content: |
| 44 | + |
| 45 | +```shell |
| 46 | +# Changelog |
| 47 | + |
| 48 | +All notable changes to this project will be documented in this file. |
| 49 | + |
| 50 | +The format is based on [Keep a Changelog](https://keepachangelog.com/) |
| 51 | +and this project adheres to [Semantic Versioning](https://semver.org/). |
| 52 | + |
| 53 | +## [Unreleased] |
| 54 | + |
| 55 | +## [0.1.0] - 2025-01-21 |
| 56 | + |
| 57 | +[Unreleased]: https://example.com/compare/v0.1.0...HEAD |
| 58 | +[0.1.0]: https://example.com/releases/tag/v0.1.0 |
| 59 | +``` |
| 60 | + |
| 61 | +This example uses default values, but title, description, url, and initial release version can be configured. |
| 62 | + |
| 63 | +### Add a new change to a release |
| 64 | + |
| 65 | +The `add` command adds a new change to the changelog file. |
| 66 | + |
| 67 | +``` |
| 68 | +changelog-parser add --type added "New feature" |
| 69 | +changelog-parser add --type security "Fix security issue" |
| 70 | +``` |
| 71 | + |
| 72 | +Those commands add the following content to the changelog file: |
| 73 | + |
| 74 | +```shell |
| 75 | +### Added |
| 76 | + |
| 77 | +- New feature |
| 78 | + |
| 79 | +### Security |
| 80 | + |
| 81 | +- Fix security issue |
| 82 | +``` |
| 83 | + |
| 84 | +### Add a new release |
| 85 | + |
| 86 | +The `release` command adds a new release to the changelog file. |
| 87 | + |
| 88 | +```shell |
| 89 | +changelog-parser release 1.0.0 |
| 90 | +``` |
| 91 | + |
| 92 | +This command adds the following content to the changelog file: |
| 93 | + |
| 94 | +```diff |
| 95 | +--- CHANGELOG.md |
| 96 | ++++ CHANGELOG.md |
| 97 | +@@ -9,2 +9,4 @@ |
| 98 | + |
| 99 | ++## [1.0.0] - 2025-01-21 |
| 100 | + |
| 101 | + ### Added |
| 102 | +@@ -19,3 +21,4 @@ |
| 103 | + |
| 104 | +-[Unreleased]: https://example.com/compare/v0.1.0...HEAD |
| 105 | ++[Unreleased]: https://example.com/compare/v1.0.0...HEAD |
| 106 | ++[1.0.0]: https://example.com/compare/v0.1.0...v1.0.0 |
| 107 | + [0.1.0]: https://example.com/releases/tag/v0.1.0 |
| 108 | +``` |
| 109 | + |
| 110 | +A date can be specified with the `--date` flag. |
| 111 | + |
| 112 | +### List all releases |
| 113 | + |
| 114 | +The `list` command lists all releases in the changelog file. |
| 115 | + |
| 116 | +```shell |
| 117 | +changelog-parser list |
| 118 | +``` |
| 119 | + |
| 120 | +This command prints the following content: |
| 121 | + |
| 122 | +```shell |
| 123 | +1.0.0 |
| 124 | +0.1.0 |
| 125 | +``` |
| 126 | + |
| 127 | +### Show all changes in a release |
| 128 | + |
| 129 | +The `show` command shows all changes in a release. |
| 130 | + |
| 131 | +```shell |
| 132 | +changelog-parser show 1.0.0 |
| 133 | +``` |
| 134 | + |
| 135 | +This command prints the following content: |
| 136 | + |
| 137 | +```shell |
| 138 | +## [1.0.0] - 2025-01-21 |
| 139 | + |
| 140 | +### Added |
| 141 | + |
| 142 | +- New feature |
| 143 | + |
| 144 | +### Security |
| 145 | + |
| 146 | +- Fix security issue |
| 147 | +``` |
| 148 | + |
| 149 | +### Merge two or more changelog files |
| 150 | + |
| 151 | +The `merge` command merges two (or more) changelog files. |
| 152 | + |
| 153 | +```shell |
| 154 | +changelog-parser merge other/CHANGELOG.md |
| 155 | +``` |
| 156 | + |
| 157 | +This command merges the content from `other/CHANGELOG.md` latest release into the current changelog file. |
| 158 | + |
| 159 | +The source release to be merged can be specified with `other/CHANGELOG.md@2.0.0`. |
| 160 | +The destination release version can be specified with `--version` flag. |
| 161 | + |
| 162 | +Multiple changelog files can be merged by specifying multiple files. |
| 163 | + |
| 164 | +## Credits |
| 165 | + |
| 166 | +- https://github.com/oscarotero/keep-a-changelog |
0 commit comments