Skip to content

Commit 9b7edfb

Browse files
authored
Merge pull request #146 from devchat-ai/support_command_with_scripyt
add required attri and output command setting
2 parents ed12c0c + a964b9a commit 9b7edfb

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

devchat/_cli/run.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ def run(command: str, list_flag: bool, recursive_flag: bool, update_sys_flag: bo
7676
if not cmd.steps:
7777
prompter = RecursivePrompter(namespace)
7878
click.echo(prompter.run(command))
79+
else:
80+
click.echo(json.dumps(cmd.dict()))
7981
return
8082

8183

devchat/engine/command_parser.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from typing import List, Dict, Optional
23
import oyaml as yaml
34
from pydantic import BaseModel
@@ -9,6 +10,7 @@ class Parameter(BaseModel, extra='forbid'):
910
description: Optional[str]
1011
enum: Optional[List[str]]
1112
default: Optional[str]
13+
required: Optional[bool]
1214

1315

1416
class Command(BaseModel, extra='forbid'):
@@ -53,7 +55,12 @@ def parse_command(file_path: str) -> Command:
5355
:param file_path: The path to the configuration file.
5456
:return: The validated configuration as a Pydantic model.
5557
"""
58+
# get path from file_path, /xx1/xx2/xx3.py => /xx1/xx2
59+
config_dir = os.path.dirname(file_path)
60+
5661
with open(file_path, 'r', encoding='utf-8') as file:
57-
config_dict = yaml.safe_load(file)
62+
# replace {curpath} with config_dir
63+
content = file.read().replace('{curpath}', config_dir)
64+
config_dict = yaml.safe_load(content)
5865
config = Command(**config_dict)
5966
return config

0 commit comments

Comments
 (0)