From cbf5e0968608c121e66bb327c9f864d40cd50dad Mon Sep 17 00:00:00 2001 From: Stefan Vogel Date: Tue, 11 Feb 2025 13:43:45 +0100 Subject: [PATCH] Strip down return codes --- src/pyProfileMgr/cmd_profile.py | 4 +-- src/pyProfileMgr/ret.py | 55 +++++++++++++-------------------- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/src/pyProfileMgr/cmd_profile.py b/src/pyProfileMgr/cmd_profile.py index e68d87a..466cce5 100644 --- a/src/pyProfileMgr/cmd_profile.py +++ b/src/pyProfileMgr/cmd_profile.py @@ -313,10 +313,10 @@ def _add_profile(args) -> Ret.CODE: profile_mgr = ProfileMgr() if args.server is None: - ret_status = Ret.CODE.RET_ERROR_NO_SERVER_URL + ret_status = Ret.CODE.RET_ERROR_MISSING_SERVER_URL LOG.print_error(PrintType.ERROR, ret_status) elif args.token is None and (args.user is None or args.password is None): - ret_status = Ret.CODE.RET_ERROR_NO_USERINFORMATION + ret_status = Ret.CODE.RET_ERROR_MISSING_USER_INFORMATION LOG.print_error(PrintType.ERROR, ret_status) print("Profiles can only be created using login credentials." + "Please provide a token using the --token option or --user/--password.") diff --git a/src/pyProfileMgr/ret.py b/src/pyProfileMgr/ret.py index 24d08a5..0cfd995 100644 --- a/src/pyProfileMgr/ret.py +++ b/src/pyProfileMgr/ret.py @@ -53,42 +53,29 @@ class CODE(IntEnum): RET_ERROR = 1 RET_ERROR_ARGPARSE = 2 # Must be 2 to match the argparse error code. RET_ERROR_FILEPATH_INVALID = 3 - RET_ERROR_WRONG_FILE_FORMAT = 4 - RET_ERROR_ISSUE_NOT_FOUND = 5 - RET_ERROR_FILE_OPEN_FAILED = 6 - RET_ERROR_NO_USERINFORMATION = 7 - RET_ERROR_PROFILE_NOT_FOUND = 8 - RET_ERROR_NO_SERVER_URL = 9 - RET_ERROR_CREATING_TICKET_FAILED = 10 - RET_ERROR_INVALID_SEARCH = 11 - RET_ERROR_INVALID_URL = 12 - RET_ERROR_BOARD_NOT_FOUND = 14 - RET_ERROR_PROFILE_ALREADY_EXISTS = 15 - RET_ERROR_INVALID_PROFILE_TYPE = 16 - RET_ERROR_MISSING_CREDENTIALS = 17 + RET_ERROR_FILE_OPEN_FAILED = 4 + RET_ERROR_MISSING_USER_INFORMATION = 5 + RET_ERROR_MISSING_CREDENTIALS = 6 + RET_ERROR_MISSING_SERVER_URL = 7 + RET_ERROR_INVALID_PROFILE_TYPE = 8 + RET_ERROR_PROFILE_NOT_FOUND = 9 + RET_ERROR_PROFILE_ALREADY_EXISTS = 10 MSG = { - CODE.RET_OK: "Process successful.", - CODE.RET_ERROR: "Error occurred.", - CODE.RET_ERROR_ARGPARSE: "Error while parsing arguments.", - CODE.RET_ERROR_FILEPATH_INVALID: "The provided filepath does not exist.", - CODE.RET_ERROR_WRONG_FILE_FORMAT: "Wrong file format for save file provided.", - CODE.RET_ERROR_ISSUE_NOT_FOUND: "Jira issue not found.", - CODE.RET_ERROR_FILE_OPEN_FAILED: "Failed to open file.", - CODE.RET_ERROR_NO_USERINFORMATION: "No user information was provided " + - "or stored information file.", - CODE.RET_ERROR_PROFILE_NOT_FOUND: "The server profile does not exist.", - CODE.RET_ERROR_NO_SERVER_URL: "To add a new profile, the server url must " + - "be provided with the --url option", - CODE.RET_ERROR_CREATING_TICKET_FAILED: "creating the ticket on the Jira server failed", - CODE.RET_ERROR_INVALID_SEARCH: "search string returned a Jira error", - CODE.RET_ERROR_INVALID_URL: "The provided server url is invalid", - CODE.RET_ERROR_BOARD_NOT_FOUND: "The Jira board does not exist or " + - "you have no access to it.", - CODE.RET_ERROR_PROFILE_ALREADY_EXISTS: "The profile you want to add already exists.\n" + - "Use the 'update' command to update it.", - CODE.RET_ERROR_INVALID_PROFILE_TYPE: "The provided profile type is invalid.", - CODE.RET_ERROR_MISSING_CREDENTIALS: "Failed to provide server credentials.", + CODE.RET_OK: "Process successful.", + CODE.RET_ERROR: "Error occurred.", + CODE.RET_ERROR_ARGPARSE: "Error while parsing arguments.", + CODE.RET_ERROR_FILEPATH_INVALID: "The provided filepath does not exist.", + CODE.RET_ERROR_FILE_OPEN_FAILED: "Failed to open file.", + CODE.RET_ERROR_MISSING_USER_INFORMATION: "Missing user information was provided " + + "or not found in file.", + CODE.RET_ERROR_MISSING_CREDENTIALS: "Failed to provide server credentials.", + CODE.RET_ERROR_MISSING_SERVER_URL: "To add a new profile, the server url must " + + "be provided with the --server option", + CODE.RET_ERROR_INVALID_PROFILE_TYPE: "The provided profile type is invalid.", + CODE.RET_ERROR_PROFILE_NOT_FOUND: "The profile does not exist.", + CODE.RET_ERROR_PROFILE_ALREADY_EXISTS: "The profile you want to add already exists.\n" + + "Use the 'update' command to update it.", }