Skip to content

Commit

Permalink
Merge pull request #3 from MaineKuehn/feature/defaults
Browse files Browse the repository at this point in the history
Basic configuration emulation
  • Loading branch information
maxfischer2781 committed Nov 7, 2019
2 parents bf2ad9e + 1d71a15 commit 8f81de1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
12 changes: 10 additions & 2 deletions change/_core.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import argparse
import shlex

from . import log

CLI = argparse.ArgumentParser(description="change and manage package information")
# TODO: add pyproject.toml defaults support

class ConfigArgumentParser(argparse.ArgumentParser):
def convert_arg_line_to_args(self, arg_line):
return shlex.split(arg_line, comments=True)


CLI = ConfigArgumentParser(
description="change and manage package information", fromfile_prefix_chars="@"
)
CMD_CLI = CLI.add_subparsers(required=True, dest="CMD")

log.mount_cli(CMD_CLI)
Expand Down
15 changes: 5 additions & 10 deletions change/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def compile(options: argparse.Namespace):


def release(options: argparse.Namespace):
release_changes(
fragment_dir=options.FRAGMENT_DIR, new_ver=options.SEMVER,
)
release_changes(fragment_dir=options.FRAGMENT_DIR, new_ver=options.SEMVER)


def mount_cli(command_cli):
Expand All @@ -67,14 +65,14 @@ def mount_cli(command_cli):
release_cli = sub_cli.add_parser("release", help="prepare unreleased fragments")
release_cli.set_defaults(action=release)
release_cli.add_argument(
"SEMVER", help="version of unreleased fragments", type=is_semver,
"SEMVER", help="version of unreleased fragments", type=is_semver
)

# CLI for writing changelogs
compile_cli = sub_cli.add_parser("compile", help="compile a changelog",)
compile_cli = sub_cli.add_parser("compile", help="compile a changelog")
compile_cli.set_defaults(action=compile)
compile_cli.add_argument(
"-o", "--output", help='output path or "-" for stdout', default="-",
"-o", "--output", help='output path or "-" for stdout', default="-"
)
compile_cli.add_argument(
"-f",
Expand Down Expand Up @@ -253,10 +251,7 @@ def release_changes(fragment_dir, new_ver: str):

# Changelog compilation
def format_release(
release: Release,
fragments: List[Fragment],
item_format: str,
categories: List[str],
release: Release, fragments: List[Fragment], item_format: str, categories: List[str]
) -> List[str]:
"""Compile the changelog section for a single release"""
lines = underline(f"[{release.semver}] - {release.date}", "=")
Expand Down

0 comments on commit 8f81de1

Please sign in to comment.