交付式项目管理devel
This commit is contained in:
parent
34b3f10c07
commit
928f874157
|
|
@ -665,29 +665,13 @@ def step_patch_signatures_url(
|
|||
# ══════════════════════════════════════════════════════
|
||||
# Step 2:查询项目
|
||||
# ══════════════════════════════════════════════════════
|
||||
|
||||
def step_query_project(non_interactive: bool = False):
|
||||
console.print("\n[bold]Step 2 · 查询项目[/bold]", style="blue")
|
||||
def list_projects():
|
||||
"""以表格形式展示所有项目"""
|
||||
projects = db.list_projects()
|
||||
if not projects:
|
||||
console.print("[red]没有找到任何项目![/red]")
|
||||
return
|
||||
|
||||
print_projects(projects)
|
||||
|
||||
if non_interactive:
|
||||
return
|
||||
|
||||
project_id = Prompt.ask("请输入要查询的项目 ID", default=None)
|
||||
project = db.get_project_by_id(int(project_id))
|
||||
if project:
|
||||
print_project_details(project)
|
||||
else:
|
||||
console.print("[red]项目 ID 不存在![/red]")
|
||||
|
||||
|
||||
def print_projects(projects: List[Project]):
|
||||
"""以表格形式展示所有项目"""
|
||||
table = Table(title="📁 项目列表", show_lines=True)
|
||||
table.add_column("ID", style="cyan", width=6)
|
||||
table.add_column("名称", style="magenta", width=20)
|
||||
|
|
@ -699,8 +683,15 @@ def print_projects(projects: List[Project]):
|
|||
console.print(table)
|
||||
|
||||
|
||||
def print_project_details(project: Project):
|
||||
def print_project_details(project_id = None, non_interactive: bool = False):
|
||||
"""打印项目详细信息"""
|
||||
console.print("\n[bold]Step 3 · 查询项目[/bold]", style="blue")
|
||||
if project_id is None and non_interactive:
|
||||
return
|
||||
if project_id is None:
|
||||
project_id = Prompt.ask("请输入要查看的项目 ID", default=None)
|
||||
project = db.get_project_by_id(int(project_id))
|
||||
|
||||
console.print(f"\n[bold]项目详情: {project.name}[/bold]")
|
||||
console.print(f"ID: {project.id}")
|
||||
console.print(f"语言: {project.language}")
|
||||
|
|
@ -725,18 +716,12 @@ def print_project_details(project: Project):
|
|||
# Step 3:删除项目
|
||||
# ══════════════════════════════════════════════════════
|
||||
|
||||
def step_delete_project(non_interactive: bool = False):
|
||||
def step_delete_project(project_id = None, non_interactive: bool = False):
|
||||
console.print("\n[bold]Step 3 · 删除项目[/bold]", style="blue")
|
||||
projects = db.list_projects()
|
||||
if not projects:
|
||||
console.print("[red]没有找到任何项目![/red]")
|
||||
return
|
||||
|
||||
print_projects(projects)
|
||||
|
||||
if non_interactive:
|
||||
if project_id is None and non_interactive:
|
||||
return
|
||||
|
||||
if project_id is None:
|
||||
project_id = Prompt.ask("请输入要删除的项目 ID", default=None)
|
||||
project = db.get_project_by_id(int(project_id))
|
||||
if project:
|
||||
|
|
@ -752,10 +737,17 @@ def step_delete_project(non_interactive: bool = False):
|
|||
# ══════════════════════════════════════════════════════
|
||||
|
||||
def step_change_requirements(
|
||||
project: Project,
|
||||
project_id = None,
|
||||
non_interactive: bool = False,
|
||||
) -> List[FunctionalRequirement]:
|
||||
console.print("\n[bold]Step 4 · 变更需求[/bold]", style="blue")
|
||||
if project_id is None and non_interactive:
|
||||
return []
|
||||
|
||||
if project_id is None:
|
||||
project_id = Prompt.ask("请输入要删除的项目 ID", default=None)
|
||||
project = db.get_project_by_id(int(project_id))
|
||||
|
||||
func_reqs = db.list_functional_requirements(project.id)
|
||||
if not func_reqs:
|
||||
console.print("[red]没有找到任何功能需求![/red]")
|
||||
|
|
@ -985,6 +977,79 @@ def cli(
|
|||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
class ProjectManager:
|
||||
def __init__(self):
|
||||
# 初始化项目管理器
|
||||
self.projects = {}
|
||||
self.current_project = None
|
||||
|
||||
def create_project(self):
|
||||
"""创建项目"""
|
||||
cli()
|
||||
|
||||
def list_projects(self):
|
||||
"""获取项目列表"""
|
||||
list_projects()
|
||||
|
||||
def delete_project(self, project_id=None):
|
||||
"""删除指定项目"""
|
||||
step_delete_project(project_id)
|
||||
|
||||
|
||||
def view_current_project_info(self):
|
||||
"""查看当前项目信息"""
|
||||
print_project_details()
|
||||
|
||||
def change_current_project_requirements(self):
|
||||
"""变更当前项目需求"""
|
||||
step_change_requirements()
|
||||
|
||||
def exit_program(self):
|
||||
"""退出程序"""
|
||||
sys.exit(0)
|
||||
|
||||
def show_help(self):
|
||||
"""显示帮助菜单"""
|
||||
help_text = """
|
||||
可用指令:
|
||||
- create: 创建新项目
|
||||
- list : 获取项目列表
|
||||
- delete : 删除指定项目
|
||||
- view : 查看当前项目信息(需先进入项目)
|
||||
- change: 变更当前项目需求(需先进入项目)
|
||||
- quit : 退出程序
|
||||
- help : 显示帮助菜单
|
||||
"""
|
||||
print(help_text)
|
||||
|
||||
|
||||
def main():
|
||||
manager = ProjectManager()
|
||||
manager.show_help()
|
||||
while True:
|
||||
command = input("请输入指令(帮助输入 'help'):")
|
||||
if command == 'help':
|
||||
manager.show_help()
|
||||
elif command.startswith('create'):
|
||||
manager.create_project()
|
||||
elif command == 'list':
|
||||
manager.list_projects()
|
||||
elif command.startswith('delete'):
|
||||
try:
|
||||
_, project_id = command.split(maxsplit=1)
|
||||
manager.delete_project(int(project_id))
|
||||
except:
|
||||
manager.delete_project()
|
||||
manager.list_projects()
|
||||
elif command == 'view':
|
||||
manager.view_current_project_info()
|
||||
elif command.startswith('change'):
|
||||
manager.change_current_project_requirements()
|
||||
elif command == 'quit':
|
||||
manager.exit_program()
|
||||
break
|
||||
else:
|
||||
print("未知指令,请重试。")
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
main()
|
||||
Loading…
Reference in New Issue