From 3d0aff3d1d47a053a678ecbec69d585cf1bbb275 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Fri, 8 Nov 2024 10:06:00 +0100 Subject: cli: ensure the program returns 0 on success and 1 on error propagate a returncode in each operation and make it the returncode of the program. Prevent sys.exit calls in post(), get() and delete() request handlers to enable cleanup code and error handling. Keep a basic error log inside the request functions if the connection can't be established or if the response contains an error code. --- ogcli | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'ogcli') diff --git a/ogcli b/ogcli index b2cbe38..f4b55d5 100755 --- a/ogcli +++ b/ogcli @@ -59,7 +59,8 @@ class CLI(): sys.exit(1) # Call the command with the same name. - getattr(self.ogcli, args.command)(sys.argv[2:]) + res = getattr(self.ogcli, args.command)(sys.argv[2:]) + sys.exit(res) if __name__ == "__main__": -- cgit v1.2.3-18-g5258