d
This commit is contained in:
29
v4/cli.py
Normal file
29
v4/cli.py
Normal file
@@ -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
v4/cli_Context.py
Normal file
8
v4/cli_Context.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class cli_Context:
|
||||||
|
def __init__(self):
|
||||||
|
self.input = ""
|
||||||
|
self.outputGreeting = ""
|
||||||
|
self.outputHelp = ""
|
||||||
|
|
||||||
|
def cli_createContext():
|
||||||
|
return cli_Context()
|
||||||
40
v4/cli_test.py
Normal file
40
v4/cli_test.py
Normal file
@@ -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"
|
||||||
|
#}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from cli import *
|
||||||
|
from cli_test import *
|
||||||
from memory_test import *
|
from memory_test import *
|
||||||
from shell import *
|
from shell import *
|
||||||
from shell_test import *
|
from shell_test import *
|
||||||
@@ -12,12 +14,18 @@ print(memory_test_shouldDeselectMismatchedItems_itemTwice())
|
|||||||
print(memory_test_shouldDetectVictory())
|
print(memory_test_shouldDetectVictory())
|
||||||
print(memory_test_shouldHideMatchingItems())
|
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_e())
|
||||||
print(shell_test_exit_exit())
|
print(shell_test_exit_exit())
|
||||||
print(shell_test_exit_q())
|
print(shell_test_exit_q())
|
||||||
print(shell_test_exit_quit())
|
print(shell_test_exit_quit())
|
||||||
|
|
||||||
c = shell_createContext()
|
c = shell_createContext()
|
||||||
|
c.cCLI = cli_createContext()
|
||||||
|
|
||||||
c = shell_start(c)
|
c = shell_start(c)
|
||||||
if c.recentField == "output":
|
if c.recentField == "output":
|
||||||
print(c.output)
|
print(c.output)
|
||||||
|
|||||||
@@ -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
|
|
||||||
#}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
class memoryCLI_Context:
|
|
||||||
def __init__(self):
|
|
||||||
self.input = ""
|
|
||||||
self.output = ""
|
|
||||||
|
|
||||||
def memoryCLI_createContext():
|
|
||||||
return memoryCLI_Context()
|
|
||||||
17
v4/shell.py
17
v4/shell.py
@@ -1,3 +1,4 @@
|
|||||||
|
from cli import *
|
||||||
from shell_Context import *
|
from shell_Context import *
|
||||||
from llm import *
|
from llm import *
|
||||||
|
|
||||||
@@ -6,7 +7,11 @@ from llm import *
|
|||||||
def shell_start(
|
def shell_start(
|
||||||
c: shell_Context
|
c: shell_Context
|
||||||
) -> 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"
|
c.recentField = "output"
|
||||||
return c
|
return c
|
||||||
#}
|
#}
|
||||||
@@ -30,7 +35,15 @@ def shell_processInput(
|
|||||||
c.recentField = "exit"
|
c.recentField = "exit"
|
||||||
return c
|
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"
|
c.recentField = "output"
|
||||||
return c
|
return c
|
||||||
#}
|
#}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class shell_Context:
|
class shell_Context:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.cCLI = None
|
||||||
self.exit = False
|
self.exit = False
|
||||||
self.input = ""
|
self.input = ""
|
||||||
self.output = ""
|
self.output = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user