diff --git a/AUTHORS b/AUTHORS index d2f7095a..f623cad5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -22,4 +22,5 @@ Jesse Jarzynka (http://jessejoe.com) László Kiss Kollár Frances Hocutt Tathagata Dasgupta -Wasim Thabraze \ No newline at end of file +Wasim Thabraze +Chad Hawkins diff --git a/README.rst b/README.rst index 48935823..6999028a 100644 --- a/README.rst +++ b/README.rst @@ -160,6 +160,7 @@ Uploads one or more distributions to a repository. [-s] [--sign-with SIGN_WITH] [-i IDENTITY] [-u USERNAME] [-p PASSWORD] [-c COMMENT] [--config-file CONFIG_FILE] [--skip-existing] [--cert path] [--client-cert path] + [--check-first] dist [dist ...] positional arguments: @@ -204,6 +205,7 @@ Uploads one or more distributions to a repository. --client-cert path Path to SSL client certificate, a single file containing the private key and the certificate in PEM format. + --check-first Check distribution files before uploading. ``twine check`` ^^^^^^^^^^^^^^^ diff --git a/twine/commands/upload.py b/twine/commands/upload.py index b4d3f933..c84e26f1 100644 --- a/twine/commands/upload.py +++ b/twine/commands/upload.py @@ -18,6 +18,7 @@ import os.path from twine.commands import _find_dists +from twine.commands.check import check from twine.package import PackageFile from twine import exceptions from twine import settings @@ -108,6 +109,12 @@ def upload(upload_settings, dists): def main(args): parser = argparse.ArgumentParser(prog="twine upload") settings.Settings.register_argparse_arguments(parser) + parser.add_argument( + "--check-first", + default=False, + action="store_true", + help="Check distribution files before uploading.", + ) parser.add_argument( "dists", nargs="+", @@ -121,5 +128,11 @@ def main(args): args = parser.parse_args(args) upload_settings = settings.Settings.from_argparse(args) + # Call the check function if specified + if args.check_first: + failed_check = check(args.dists) + if failed_check: + return + # Call the upload function with the arguments from the command line return upload(upload_settings, args.dists)