Skip to content

Commit

Permalink
*DIR and *INFO
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Aug 26, 2021
1 parent aeaee64 commit 434d863
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ References:
- */
- *FX
- *BASIC
- *DIR
- *HELP
- *HOST cmd: execute a command on the host OS. Example: `*HOST ls -la`
- *INFO
- *LOAD
- *QUIT: exit to host
- *RUN
Expand Down
43 changes: 36 additions & 7 deletions osCLI.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"os"
"os/exec"
"strconv"
"strings"
Expand All @@ -19,9 +20,11 @@ var cliCommands = []string{
"FX",
"BASIC",
"CODE",
"DIR",
"EXEC",
"HELP",
"HOST", // Added for bbz
"INFO",
"KEY",
"LOAD",
"LINE",
Expand Down Expand Up @@ -127,6 +130,24 @@ func execOSCLI(env *environment) {

case "CODE":
execOSCLIfx(env, 0x88, strings.Split(args, ","))

case "DIR":
dest := args
if len(dest) == 0 {
var err error
dest, err = os.UserHomeDir()
if err != nil {
env.raiseError(errorTodo, err.Error())
break
}
}

err := os.Chdir(dest)
if err != nil {
env.raiseError(206, "Bad directory")
break
}

//case "EXEC":

case "HELP":
Expand All @@ -140,14 +161,22 @@ func execOSCLI(env *environment) {
case "HOST":
if len(args) == 0 {
env.raiseError(errorTodo, "Command missing for *HOST")
break
}
params := strings.Split(args, " ")
cmd := exec.Command(params[0], params[1:]...)
stdout, err := cmd.Output()
if err != nil {
env.raiseError(errorTodo, err.Error())
}
fmt.Println(string(stdout))

case "INFO":
attr := getFileAttributes(env, args)
if attr.hasMetadata {
fmt.Printf("%s\t %06X %06X %06X\n", args, attr.loadAddress, attr.executionAddress, attr.fileSize)
} else {
params := strings.Split(args, " ")
cmd := exec.Command(params[0], params[1:]...)
stdout, err := cmd.Output()
if err != nil {
env.raiseError(errorTodo, err.Error())
}
fmt.Println(string(stdout))
fmt.Printf("%s\t ?????? ?????? %06X\n", args, attr.fileSize)
}

// case "KEY":
Expand Down

0 comments on commit 434d863

Please sign in to comment.