refine code

This commit is contained in:
geekan 2023-12-19 17:11:02 +08:00
parent 7f04ec2060
commit 2bae7f2bfb
2 changed files with 13 additions and 5 deletions

View file

@ -45,6 +45,7 @@ class Config(metaclass=Singleton):
default_yaml_file = METAGPT_ROOT / "config/config.yaml"
def __init__(self, yaml_file=default_yaml_file):
self._init_cli_paras()
self._init_with_config_files_and_env(yaml_file)
self._update()
logger.debug("Config loading done.")
@ -130,8 +131,20 @@ class Config(metaclass=Singleton):
self.workspace_path = Path(self._get("WORKSPACE_PATH", DEFAULT_WORKSPACE_ROOT))
self._ensure_workspace_exists()
def _init_cli_paras(self):
self.project_path = None
self.project_name = None
self.inc = None
self.reqa_file = None
self.max_auto_summarize_code = None
def update_via_cli(self, project_path, project_name, inc, reqa_file, max_auto_summarize_code):
"""update config via cli"""
# Use in the PrepareDocuments action according to Section 2.2.3.5.1 of RFC 135.
if project_path:
inc = True
project_name = project_name or Path(project_path).name
self.project_path = project_path
self.project_name = project_name
self.inc = inc