Skip to content

Commit

Permalink
*TYPE
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Sep 13, 2021
1 parent 7e4bb59 commit 6dbb656
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 31 deletions.
40 changes: 22 additions & 18 deletions osCLI.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var cliCommands = []string{
"SPOOL",
"TAPE",
"TV",
"TYPE",
}

func execOSCLI(env *environment) {
Expand Down Expand Up @@ -116,24 +117,7 @@ func execOSCLI(env *environment) {
}

case "CAT":
// *CAT filename
filename := ""
_, filename, valid = parseFilename(line, pos)
if !valid {
env.raiseError(254, "Bad Command")
break
}

if filename != "" {
data, err := os.ReadFile(filename)
if err != nil {
env.raiseError(errorTodo, err.Error())
break
}
for _, ch := range data {
env.vdu.write(ch)
}
}
env.con.write("<cat placeholder>\n")

case "CODE":
execOSCLIfx(env, 0x88, line, pos)
Expand Down Expand Up @@ -387,6 +371,26 @@ func execOSCLI(env *environment) {
case "TV":
execOSCLIfx(env, 0x90, line, pos)

case "TYPE":
// *TYPE filename
filename := ""
_, filename, valid = parseFilename(line, pos)
if !valid {
env.raiseError(254, "Bad Command")
break
}

if filename != "" {
data, err := os.ReadFile(filename)
if err != nil {
env.raiseError(errorTodo, err.Error())
break
}
for _, ch := range data {
env.vdu.write(ch)
}
}

default:
unhandled = true
}
Expand Down
16 changes: 3 additions & 13 deletions osCLI_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func Test_OSCLI_FX_spaces(t *testing.T) {
}
}

func Test_OSCLI_CAT(t *testing.T) {
func Test_OSCLI_TYPE(t *testing.T) {
source := "Hi []{}"
printed := "Hi ←→¼¾>"

Expand All @@ -58,21 +58,11 @@ func Test_OSCLI_CAT(t *testing.T) {
}

out := integrationTestBasic([]string{
"*CAT " + file.Name(),
"*TYPE " + file.Name(),
})

if !strings.Contains(out, printed) {
t.Log(out)
t.Error("*CAT error")
t.Error("*TYPE error")
}

out2 := integrationTestBasic([]string{
"*CAT " + file.Name(),
})

if !strings.Contains(out2, printed) {
t.Log(out)
t.Error("*. error")
}

}

0 comments on commit 6dbb656

Please sign in to comment.