Add handling for existing shipments and improve update functionality in __main__.py

The current code adds handling for existing shipments and improves the update functionality in the `__main__.py` file. The changes include checking if a shipment already exists, updating the shipment with the specified carrier, and printing appropriate messages.
This commit is contained in:
Kumi 2023-09-12 08:35:10 +02:00
parent ecc540ab6e
commit f7e9c76f64
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -127,7 +127,7 @@ def main():
if args.tracking_number is not None and args.carrier is not None: if args.tracking_number is not None and args.carrier is not None:
if ( if (
shipment := tracker.db.get_shipment(args.tracking_number) (shipment := tracker.db.get_shipment(args.tracking_number))
and not args.update and not args.update
): ):
print(f"Shipment {args.tracking_number} already exists. Use -u to update.") print(f"Shipment {args.tracking_number} already exists. Use -u to update.")
@ -140,6 +140,7 @@ def main():
print( print(
f"Updated shipment for {args.tracking_number} with carrier {args.carrier}" f"Updated shipment for {args.tracking_number} with carrier {args.carrier}"
) )
exit(0)
if not shipment and args.update: if not shipment and args.update:
print(f"Shipment {args.tracking_number} does not exist. Remove -u to create.") print(f"Shipment {args.tracking_number} does not exist. Remove -u to create.")