From 05ad4268cf7ac38218b3a57fd84b7a6a4b0358fd Mon Sep 17 00:00:00 2001 From: mulhern Date: Wed, 30 Aug 2023 13:25:16 -0400 Subject: [PATCH 1/2] Hoist --dry-run option up to the top parser Everything can implement dry-running, so that option can be global. Signed-off-by: mulhern --- release_management/create_release.py | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/release_management/create_release.py b/release_management/create_release.py index 2b812e0..be86c13 100755 --- a/release_management/create_release.py +++ b/release_management/create_release.py @@ -132,14 +132,6 @@ def set_up_subcommand( func=lambda namespace: RustCrates.tag_rust_library(namespace, subcmd) ) - new_subparser.add_argument( - "--dry-run", - action="store_true", - default=False, - dest="dry_run", - help="Only report actions, do not do them", - ) - new_subparser.add_argument( "--no-publish", action="store_true", @@ -291,14 +283,6 @@ def set_up_subcommand(subcmd, subparsers, *, add_github_release_option=False): else: new_subparser.set_defaults(no_github_release=True) - new_subparser.add_argument( - "--dry-run", - action="store_true", - default=False, - dest="dry_run", - help="Only report actions, do not do them", - ) - @staticmethod def tag_python_library(namespace, name): """ @@ -343,6 +327,14 @@ def _get_parser(): """ parser = argparse.ArgumentParser(description="Create a GitHub Draft release.") + parser.add_argument( + "--dry-run", + action="store_true", + default=False, + dest="dry_run", + help="Only report actions, do not do them", + ) + parser.add_argument( "--no-tag", action="store_true", From ec4b29e970cc1dbf561600bc673ed0c50c9d5106 Mon Sep 17 00:00:00 2001 From: mulhern Date: Wed, 30 Aug 2023 14:50:44 -0400 Subject: [PATCH 2/2] Make command tree a bit deeper Signed-off-by: mulhern --- release_management/create_release.py | 80 +++++++++++++++++----------- 1 file changed, 49 insertions(+), 31 deletions(-) diff --git a/release_management/create_release.py b/release_management/create_release.py index be86c13..c3d2755 100755 --- a/release_management/create_release.py +++ b/release_management/create_release.py @@ -321,37 +321,7 @@ def tag_python_library(namespace, name): ) -def _get_parser(): - """ - Build parser - """ - parser = argparse.ArgumentParser(description="Create a GitHub Draft release.") - - parser.add_argument( - "--dry-run", - action="store_true", - default=False, - dest="dry_run", - help="Only report actions, do not do them", - ) - - parser.add_argument( - "--no-tag", - action="store_true", - default=False, - dest="no_tag", - help="only create artifacts", - ) - - parser.add_argument( - "--no-release", - action="store_true", - default=False, - dest="no_release", - help="stop before pushing any changes to GitHub repo", - ) - - subparsers = parser.add_subparsers(title="subcommands") +def _create_rust_subcommands(subparsers): RustCrates.set_up_subcommand( "stratisd", @@ -390,6 +360,9 @@ def _get_parser(): RustCrates.set_up_subcommand("stratisd_proc_macros", subparsers) + +def _create_python_subcommands(subparsers): + PythonPackages.set_up_subcommand( "stratis-cli", subparsers, add_github_release_option=True ) @@ -412,6 +385,51 @@ def _get_parser(): PythonPackages.set_up_subcommand("testing", subparsers) + +def _get_parser(): + """ + Build parser + """ + parser = argparse.ArgumentParser(description="Create a GitHub Draft release.") + + parser.add_argument( + "--dry-run", + action="store_true", + default=False, + dest="dry_run", + help="Only report actions, do not do them", + ) + + parser.add_argument( + "--no-tag", + action="store_true", + default=False, + dest="no_tag", + help="only create artifacts", + ) + + parser.add_argument( + "--no-release", + action="store_true", + default=False, + dest="no_release", + help="stop before pushing any changes to GitHub repo", + ) + + subparsers = parser.add_subparsers(title="subcommands") + + rust_subparser = subparsers.add_parser( + "rust", help="Create a release for a rust package." + ) + + _create_rust_subcommands(rust_subparser) + + python_subparser = subparsers.add_parser( + "python", help="Create a release for a python package." + ) + + _create_python_subcommands(python_subparser) + return parser