nvcmp: optionally exit with 4 if there are differences

closes #196.
This commit is contained in:
lilydjwg 2022-02-28 14:07:46 +08:00
parent f4e9ab80b9
commit c6ed37ada1

View File

@ -83,6 +83,8 @@ def cmp() -> None:
'(default: parse_version)')
parser.add_argument('-n', '--newer', action='store_true',
help='Shows only the newer ones according to --sort.')
parser.add_argument('--exit-status', action='store_true',
help="exit with status 4 if there are updates")
args = parser.parse_args()
if core.process_common_arguments(args):
return
@ -182,3 +184,8 @@ def cmp() -> None:
style = diffstyles[diff.get('delta', 'equal')] # type: ignore # mypy has issues with this line
print(f'{diff["name"]} {style["oldc"]}{diff["oldver"]}{c.normal} {style["symbol"]} {c.green}{diff["newver"]}{c.normal}')
if args.exit_status and any(
diff.get('delta') != 'equal' for diff in differences
):
sys.exit(4)