From a3ad83ec32fb702b85aedac1cac5ac0f1e04f10f Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Sat, 24 Apr 2021 02:58:59 -0700 Subject: [PATCH] Bug fixes and readme --- CHANGELOG.md | 9 ++++++ README.md | 69 +++++++++++++++++++++++++++++++++++++++++- setup.cfg | 4 +++ yaclog/cli/__main__.py | 8 +++-- 4 files changed, 86 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aaf6e71..023b3b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,19 @@ All notable changes to this project will be documented in this file ## Unreleased +### Added + +- Readme file now has installation and usage instructions +- yaclog command entry point added to setup.cfg + ### Changed - `release -c` will no longer create empty commits, and will use the current commit instead +### Fixed + +- `release` and `entry` commands now work using empty changelogs + ## 0.3.1 - 2021-04-24 ### Added diff --git a/README.md b/README.md index c2759ae..6e2c2fa 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,71 @@ Yet another changelog command line tool ![a yak who is a log](https://github.com/drewcassidy/yaclog/raw/main/logo.png) -*Logo by Erin Cassidy* \ No newline at end of file +*Logo by Erin Cassidy* + +## Installation + +Install and update using [pip](https://pip.pypa.io/en/stable/quickstart/): + +```shell +$ pip install -U yaclog +``` + +## Usage + +For usage from the command line, yaclog provides the `yaclog` command: +``` +Usage: yaclog [OPTIONS] COMMAND [ARGS]... + + Manipulate markdown changelog files. + +Options: + --path FILE Location of the changelog file. [default: CHANGELOG.md] + --version Show the version and exit. + --help Show this message and exit. + +Commands: + entry Add entries to the changelog. + format Reformat the changelog file. + init Create a new changelog file. + release Release versions. + show Show changes from the changelog file + tag Modify version tags +``` + +### Example workflow + +Create a new changelog: +```shell +$ yaclog init +``` + +Add some new entries to the "Added" section of the current unreleased version: +```shell +$ yaclog entry -b 'Introduced some more bugs' +$ yaclog entry -b 'Introduced some more features' +``` + +Show the current version: + +```shell +$ yaclog show +``` +``` +Unreleased + +- Introduced some more bugs +- Introduced some more features +``` + +Release the current version and make a git tag for it + +```shell +$ yaclog release --version 0.0.1 -c +``` +``` +Renamed version "Unreleased" to "0.0.1". +Commit and create tag for version 0.0.1? [y/N]: y +Created commit a7b6789 +Created tag "0.0.1". +``` diff --git a/setup.cfg b/setup.cfg index 20d585a..e615652 100644 --- a/setup.cfg +++ b/setup.cfg @@ -33,3 +33,7 @@ install_requires = packaging >= 20 python_requires = >= 3.8 packages = find: + +[options.entry_points] +console_scripts = + yaclog = yaclog.cli.__main__:cli diff --git a/yaclog/cli/__main__.py b/yaclog/cli/__main__.py index b00d958..07f1ae3 100644 --- a/yaclog/cli/__main__.py +++ b/yaclog/cli/__main__.py @@ -139,10 +139,12 @@ def entry(obj: Changelog, bullets, paragraphs, section_name, version_name): raise click.BadArgumentUsage(f'Version "{version_name}" not found in changelog.') version = matches[0] else: - version = obj.versions[0] - if version.name.lower() != 'unreleased': + matches = [v for v in obj.versions if v.name.lower() == 'unreleased'] + if len(matches) == 0: version = yaclog.changelog.VersionEntry() obj.versions.insert(0, version) + else: + version = matches[0] if section_name not in version.sections.keys(): version.sections[section_name] = [] @@ -167,7 +169,7 @@ def entry(obj: Changelog, bullets, paragraphs, section_name, version_name): obj.write() -@cli.command() +@cli.command(short_help='Release versions.') @click.option('-v', '--version', 'v_flag', type=str, default=None, help='The new version number to use.') @click.option('-M', '--major', 'v_flag', flag_value='+M', help='Increment major version number.') @click.option('-m', '--minor', 'v_flag', flag_value='+m', help='Increment minor version number.')