Skip to content

Commit

Permalink
tccli优先展示产品推荐版本 (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
HS-Gray authored Mar 19, 2024
1 parent 1f8b2cb commit 79ef53d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 1 addition & 3 deletions tccli/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(".")
Expand Down
7 changes: 4 additions & 3 deletions tccli/document_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
13 changes: 12 additions & 1 deletion tccli/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 79ef53d

Please sign in to comment.