Compare commits
No commits in common. "1e82d18604f3b68fb0854434a1e9f009254b3796" and "7dfe709e75db501eb9c8be36a8edf5ddac0cb52a" have entirely different histories.
1e82d18604
...
7dfe709e75
87
cmd/main.go
87
cmd/main.go
@ -1,87 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"git.defalsify.org/vise.git/engine"
|
||||
|
||||
"git.defalsify.org/vise.git/resource"
|
||||
"git.defalsify.org/vise.git/state"
|
||||
)
|
||||
|
||||
const (
|
||||
USERFLAG_LANGUAGE_SET = iota + state.FLAG_USERSTART
|
||||
)
|
||||
|
||||
type fsData struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func (fsd *fsData) SetLanguageSelected(ctx context.Context, sym string, input []byte) (resource.Result, error) {
|
||||
inputStr := string(input)
|
||||
res := resource.Result{}
|
||||
|
||||
switch inputStr {
|
||||
case "0":
|
||||
res.FlagSet = []uint32{state.FLAG_LANG}
|
||||
res.Content = "eng"
|
||||
case "1":
|
||||
res.FlagSet = []uint32{state.FLAG_LANG}
|
||||
res.Content = "swa"
|
||||
default:
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
var dir string
|
||||
var root string
|
||||
var size uint
|
||||
var sessionId string
|
||||
var persist bool
|
||||
flag.StringVar(&dir, "d", ".", "resource dir to read from")
|
||||
flag.UintVar(&size, "s", 0, "max size of output")
|
||||
flag.StringVar(&root, "root", "root", "entry point symbol")
|
||||
flag.StringVar(&sessionId, "session-id", "default", "session id")
|
||||
flag.BoolVar(&persist, "persist", false, "use state persistence")
|
||||
flag.Parse()
|
||||
fmt.Fprintf(os.Stderr, "starting session at symbol '%s' using resource dir: %s\n", root, dir)
|
||||
|
||||
fp := path.Join(dir, sessionId)
|
||||
fs := &fsData{
|
||||
path: fp,
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
en, rs, err := engine.NewSizedEnginee(dir, uint32(size), persist, &sessionId)
|
||||
rs.AddLocalFunc("select_language", fs.SetLanguageSelected)
|
||||
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "engine create error: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
cont, err := en.Init(ctx)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "engine init exited with error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if !cont {
|
||||
_, err = en.WriteResult(ctx, os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "dead init write error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
os.Stdout.Write([]byte{0x0a})
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
err = engine.Loop(ctx, en, os.Stdin, os.Stdout)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "loop exited with error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ=
|
||||
github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
|
||||
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
|
@ -1,17 +0,0 @@
|
||||
# Variables to match files in the current directory
|
||||
INPUTS = $(wildcard ./*.vis)
|
||||
TXTS = $(wildcard ./*.txt.orig)
|
||||
|
||||
# Rule to build .bin files from .vis files
|
||||
%.vis:
|
||||
go run ../../go-vise/dev/asm $(basename $@).vis > $(basename $@).bin
|
||||
@echo "Built $(basename $@).bin from $(basename $@).vis"
|
||||
|
||||
# Rule to copy .orig files to .txt
|
||||
%.txt.orig:
|
||||
cp -v $(basename $@).orig $(basename $@)
|
||||
@echo "Copied $(basename $@).orig to $(basename $@)"
|
||||
|
||||
# 'all' target depends on all .vis and .txt.orig files
|
||||
all: $(INPUTS) $(TXTS)
|
||||
@echo "Running all: $(INPUTS) $(TXTS)"
|
@ -1 +0,0 @@
|
||||
Welcome to Sarafu Network
|
@ -1,7 +0,0 @@
|
||||
LOAD select_language 0
|
||||
MOUT english 0
|
||||
MOUT kiswahili 1
|
||||
HALT
|
||||
INCMP terms 0
|
||||
INCMP terms 1
|
||||
RELOAD select_language
|
@ -1 +0,0 @@
|
||||
Karibu Sarafu Network
|
@ -1 +0,0 @@
|
||||
Do you agree to terms and conditions?
|
@ -1,2 +0,0 @@
|
||||
MOUT yes 0
|
||||
MOUT no 1
|
@ -1 +0,0 @@
|
||||
Kwa kutumia hii huduma umekubali sheria na masharti?
|
Loading…
Reference in New Issue
Block a user