diff --git a/client-cli/pvc/cli/formatters.py b/client-cli/pvc/cli/formatters.py index 518bd583..951a22e1 100644 --- a/client-cli/pvc/cli/formatters.py +++ b/client-cli/pvc/cli/formatters.py @@ -905,7 +905,7 @@ def cli_connection_list_format_pretty(CLI_CONFIG, data): # Parse each connection and adjust field lengths for connection in data: for field, length in [(f, fields[f]["length"]) for f in fields]: - _length = len(str(connection[field])) + _length = len(str(connection[field])) + 1 if _length > length: length = len(str(connection[field])) + 1 @@ -1005,7 +1005,7 @@ def cli_connection_detail_format_pretty(CLI_CONFIG, data): # Parse each connection and adjust field lengths for connection in data: for field, length in [(f, fields[f]["length"]) for f in fields]: - _length = len(str(connection[field])) + _length = len(str(connection[field])) + 1 if _length > length: length = len(str(connection[field])) + 1 diff --git a/client-cli/pvc/cli/helpers.py b/client-cli/pvc/cli/helpers.py index 9c72f623..3a9226a4 100644 --- a/client-cli/pvc/cli/helpers.py +++ b/client-cli/pvc/cli/helpers.py @@ -167,9 +167,17 @@ def get_store(store_path): with open(store_file) as fh: try: store_data = jload(fh) - return store_data except Exception: - return dict() + store_data = dict() + + if path.exists(DEFAULT_STORE_DATA["cfgfile"]): + if store_data.get("local", None) != DEFAULT_STORE_DATA: + del store_data["local"] + if "local" not in store_data.keys(): + store_data["local"] = DEFAULT_STORE_DATA + update_store(store_path, store_data) + + return store_data def update_store(store_path, store_data): diff --git a/client-cli/pvc/cli/parsers.py b/client-cli/pvc/cli/parsers.py index 267f064a..4e75eda2 100644 --- a/client-cli/pvc/cli/parsers.py +++ b/client-cli/pvc/cli/parsers.py @@ -68,7 +68,8 @@ def cli_connection_list_parser(connections_config, show_keys_flag): } ) - return connections_data + # Return, ensuring local is always first + return sorted(connections_data, key=lambda x: (x.get("name") != "local")) def cli_connection_detail_parser(connections_config):