Михаил Капелько 1周前
父节点
当前提交
251da5d3f9
共有 8 个文件被更改,包括 101 次插入29 次删除
  1. +29
    -0
      v4/cli.py
  2. +8
    -0
      v4/cli_Context.py
  3. +40
    -0
      v4/cli_test.py
  4. +8
    -0
      v4/main.py
  5. +0
    -20
      v4/memoryCLI.py
  6. +0
    -7
      v4/memoryCLI_Context.py
  7. +15
    -2
      v4/shell.py
  8. +1
    -0
      v4/shell_Context.py

+ 29
- 0
v4/cli.py 查看文件

@@ -0,0 +1,29 @@
from cli_Context import *
from llm import *

# Greet the user
@llm_by_value
def cli_greetUser(
c: cli_Context
) -> cli_Context:
c.outputGreeting = "OGS Memory Textual UI"
c.recentField = "outputGreeting"
return c
#}

# Show help (aka commands)
@llm_by_value
def cli_showHelp(
c: cli_Context
) -> cli_Context:
if (
c.input == "h" or
c.input == "help"
):
c.outputHelp = "Commands:\n\te, exit, q, quit\n\t\tExit\n\th, help\n\t\tList commands\n"
c.recentField = "outputHelp"
return c

c.recentField = "none"
return c
#}

+ 8
- 0
v4/cli_Context.py 查看文件

@@ -0,0 +1,8 @@
class cli_Context:
def __init__(self):
self.input = ""
self.outputGreeting = ""
self.outputHelp = ""

def cli_createContext():
return cli_Context()

+ 40
- 0
v4/cli_test.py 查看文件

@@ -0,0 +1,40 @@
from cli import *
from cli_Context import *

def cli_test_greetUser(
) -> str:
c = cli_createContext()
c = cli_greetUser(c)
if (
c.recentField == "outputGreeting"
):
return "OK: cli_greetUser"
#}
return "ERR: cli_greetUser"
#}

def cli_test_showHelp_h(
) -> str:
c = cli_createContext()
c.input = "h"
c = cli_showHelp(c)
if (
c.recentField == "outputHelp"
):
return "OK: cli_showHelp_h"
#}
return "ERR: cli_showHelp_h"
#}

def cli_test_showHelp_help(
) -> str:
c = cli_createContext()
c.input = "help"
c = cli_showHelp(c)
if (
c.recentField == "outputHelp"
):
return "OK: cli_showHelp_help"
#}
return "ERR: cli_showHelp_help"
#}

+ 8
- 0
v4/main.py 查看文件

@@ -1,3 +1,5 @@
from cli import *
from cli_test import *
from memory_test import *
from shell import *
from shell_test import *
@@ -12,12 +14,18 @@ print(memory_test_shouldDeselectMismatchedItems_itemTwice())
print(memory_test_shouldDetectVictory())
print(memory_test_shouldHideMatchingItems())

print(cli_test_greetUser())
print(cli_test_showHelp_h())
print(cli_test_showHelp_help())

print(shell_test_exit_e())
print(shell_test_exit_exit())
print(shell_test_exit_q())
print(shell_test_exit_quit())

c = shell_createContext()
c.cCLI = cli_createContext()

c = shell_start(c)
if c.recentField == "output":
print(c.output)


+ 0
- 20
v4/memoryCLI.py 查看文件

@@ -1,20 +0,0 @@
from memoryCLI_Context import *
from llm import *

# Greet the user.
#
# Conditions:
# 1. No input is present (the app just got launched)
@llm_by_value
def memoryCLI_greetUser(
c: memoryCLI_Context
) -> memoryCLI_Context:
if (
c.input == ""
):
c.output = "OGS Memory TextUI greets you, %USERNAME%. Let's play!"
c.recentField = "output"
return c
c.recentField = "none"
return c
#}

+ 0
- 7
v4/memoryCLI_Context.py 查看文件

@@ -1,7 +0,0 @@
class memoryCLI_Context:
def __init__(self):
self.input = ""
self.output = ""

def memoryCLI_createContext():
return memoryCLI_Context()

+ 15
- 2
v4/shell.py 查看文件

@@ -1,3 +1,4 @@
from cli import *
from shell_Context import *
from llm import *

@@ -6,7 +7,11 @@ from llm import *
def shell_start(
c: shell_Context
) -> shell_Context:
c.output = "Shell.StartText"
c.cCLI = cli_greetUser(c.cCLI)
c.cCLI.input = "help"
c.cCLI = cli_showHelp(c.cCLI)
c.output = c.cCLI.outputGreeting + "\n" + c.cCLI.outputHelp
c.recentField = "output"
return c
#}
@@ -30,7 +35,15 @@ def shell_processInput(
c.recentField = "exit"
return c

c.output = "TODO Call all CLI functions, let them process game input"
c.cCLI.input = c.input
c.output = ""

c.cCLI = cli_showHelp(c.cCLI)
if (
c.cCLI.recentField == "outputHelp"
):
c.output += c.cCLI.outputHelp

c.recentField = "output"
return c
#}

+ 1
- 0
v4/shell_Context.py 查看文件

@@ -1,5 +1,6 @@
class shell_Context:
def __init__(self):
self.cCLI = None
self.exit = False
self.input = ""
self.output = ""


正在加载...
取消
保存