diff --git a/tccli/configure.py b/tccli/configure.py index 711a327fc9..d072995ca6 100644 --- a/tccli/configure.py +++ b/tccli/configure.py @@ -74,9 +74,7 @@ def _init_configure(self, profile_name, input_data, extra={}): # as has been changed to autoscaling only in python sdk & cli if mod == 'autoscaling': conf_data[mod]["endpoint"] = "as.tencentcloudapi.com" - versions = self._cli_data.get_service_all_version_actions(mod).keys() - version = sorted(versions)[-1] - conf_data[mod]["version"] = version + conf_data[mod]["version"] = self._cli_data.get_available_services()[mod][0] for k in extra.keys(): try: ks = k.split(".") diff --git a/tccli/document_handler.py b/tccli/document_handler.py index e8a3a05f39..e923af3f41 100644 --- a/tccli/document_handler.py +++ b/tccli/document_handler.py @@ -80,9 +80,10 @@ def available_versions(self): self.doc.style.h2('Available Versions') versions = self._cli_data.get_available_services()[self._service] for version in versions: - self.doc.doc_title_indent(version) - # self.doc.style.new_line() - self.doc.doc_description_indent(u"默认只展示最新版本信息,查看其它版本帮助信息加 --version xxxx-xx-xx") + if version == versions[0]: + self.doc.doc_title_indent(version + " (recommended)") + else: + self.doc.doc_title_indent(version) def description(self): self.doc.style.h2('Description') diff --git a/tccli/loaders.py b/tccli/loaders.py index 240c46916d..b4a02425bc 100644 --- a/tccli/loaders.py +++ b/tccli/loaders.py @@ -4,6 +4,7 @@ import six import copy import json +import sys from tccli.utils import Utils from tccli import __version__ from tccli.services import SERVICE_VERSIONS @@ -177,7 +178,17 @@ def get_available_services(self): return SERVICE_VERSIONS def get_service_default_version(self, service): - return self.get_available_services()[service][0] + args = sys.argv[1:] + profile = os.environ.get("TCCLI_PROFILE", "default") + if "--profile" in args: + location = args.index("--profile") + 1 + if location < len(args): + profile = args[location] + conf_path = os.path.join(os.path.expanduser("~"), ".tccli") + conf = {} + if Utils.file_existed(conf_path, profile+".configure")[0]: + conf = Utils.load_json_msg(os.path.join(conf_path, profile+".configure")) + return conf.get(service, {}).get("version", self.get_available_services()[service][0]) def get_service_model(self, service, version): services_path = self.get_services_path()