-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
See: #5
- Loading branch information
Showing
4 changed files
with
100 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,96 @@ | ||
import click | ||
|
||
import changelog_binder.types | ||
|
||
|
||
@click.group() | ||
def main(): | ||
"""Main entry-point of the changelog-binder tool""" | ||
|
||
|
||
def with_list_options(obj): | ||
decorators = [ | ||
click.option( | ||
"--to", | ||
metavar="VERSION", | ||
help="List all fragments up to the given version", | ||
), | ||
click.option( | ||
"--from", | ||
"from_", | ||
metavar="VERSION", | ||
help=" ".join( | ||
[ | ||
"List all fragments from the given version and up to", | ||
"either HEAD or the version passed using the '--to'", | ||
"argument", | ||
] | ||
), | ||
), | ||
click.option( | ||
"--in", | ||
"in_", | ||
metavar="VERSION", | ||
help=" ".join( | ||
[ | ||
"List all fragments included in the given version,", | ||
"and not in its preceding version", | ||
] | ||
), | ||
), | ||
] | ||
|
||
for decorator in decorators: | ||
obj = decorator(obj) | ||
|
||
return obj | ||
|
||
|
||
@main.command() | ||
@with_list_options | ||
def list(in_, from_, to): | ||
"""List fragments that will be rendered""" | ||
raise NotImplementedError | ||
|
||
|
||
@main.command() | ||
@with_list_options | ||
@click.option( | ||
"--in", | ||
"in_", | ||
metavar="VERSION", | ||
help=" ".join( | ||
[ | ||
"List all fragments included in the given version,", | ||
"and not in its preceding version", | ||
] | ||
), | ||
"--release-notes", | ||
"release_notes", | ||
is_flag=True, | ||
help="Only render fragments tagged as release notes entries", | ||
) | ||
@click.option( | ||
"--from", | ||
"from_", | ||
metavar="VERSION", | ||
help=" ".join( | ||
[ | ||
"List all fragments from the given version and up to either HEAD", | ||
"or the version passed using the '--to' argument", | ||
] | ||
"--kind", | ||
"kinds", | ||
type=click.Choice( | ||
kind.name.lower() for kind in changelog_binder.types.Kind | ||
), | ||
multiple=True, | ||
help="Only render fragments of given kind(s)", | ||
) | ||
@click.option( | ||
"--to", | ||
metavar="VERSION", | ||
help="List all fragments up to the given version", | ||
"--epic", | ||
"epics", | ||
multiple=True, | ||
help="Only render fragments of given epic(s)", | ||
) | ||
def list(in_, from_, to): | ||
"""List fragments that will be rendered""" | ||
@click.option( | ||
"--no-epic", | ||
"no_epic", | ||
is_flag=True, | ||
help="Only render fragments without specified epic", | ||
) | ||
@click.option( | ||
"-o", | ||
"--output", | ||
type=click.Choice( | ||
fmt.name.lower() for fmt in changelog_binder.types.OutputFormat | ||
), | ||
default="restructuredtext", | ||
help="Output format", | ||
) | ||
def render(in_, from_, to, release_notes, kinds, epics, no_epic, output): | ||
"""Render the changelog from fragments""" | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import enum | ||
|
||
|
||
class Kind(enum.Enum): | ||
"""Kind (of change) of a fragment""" | ||
|
||
FEATURE = enum.auto() | ||
BUGFIX = enum.auto() | ||
IMPROVEMENT = enum.auto() | ||
|
||
|
||
class OutputFormat(enum.Enum): | ||
"""Output format the tool can generate""" | ||
|
||
RESTRUCTUREDTEXT = enum.auto() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.