diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..ab24ab8 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,26 @@ +name: Build + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.21.6 + - name: Build + run: | + make test + - name: Site + run: | + make site-deploy + env: + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 485dee6..0ed5507 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ .idea +build +# Local Netlify folder +.netlify diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..86d3564 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +clean: + -rm -r build + +test: + go test ./cmdlang/... + +site: clean + mkdir build + mkdir build/site + cp -r _site/* build/site/. + GOOS=js GOARCH=wasm go build -o build/site/playwasm.wasm ./cmd/playwasm/. + +site-deploy: site + netlify deploy --dir build/site --prod \ No newline at end of file diff --git a/_site/index.html b/_site/index.html new file mode 100644 index 0000000..31ca24b --- /dev/null +++ b/_site/index.html @@ -0,0 +1,33 @@ + + + + + + + + +
+

UCL

+
+ +
+

Playground

+ +
+ + + +
+ + + + \ No newline at end of file diff --git a/_site/main.js b/_site/main.js index a5bba93..e2ca493 100644 --- a/_site/main.js +++ b/_site/main.js @@ -2,14 +2,15 @@ import "xterm"; import "wasm_exec"; -var term = new Terminal(); +var term = new Terminal({ + lineHeight: 1.2, +}); term.open(document.getElementById('terminal')); function startSession(term) { let buffer = ""; let lineBuffer = ""; - term.writeln('Interactive mode'); term.write('> '); term.onKey((ev, dom) => { @@ -53,6 +54,7 @@ function startSession(term) { } ucl.onOutLine = (line) => { term.writeln(line); } ucl.onError = (err) => { term.writeln('error: ' + err); } + term.focus(); } const go = new Go(); diff --git a/_site/playground.html b/_site/playground.html deleted file mode 100644 index 011d1e1..0000000 --- a/_site/playground.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - -

Playground

- -
- - - - - \ No newline at end of file diff --git a/_site/style.css b/_site/style.css new file mode 100644 index 0000000..34bb4fa --- /dev/null +++ b/_site/style.css @@ -0,0 +1,5 @@ +#terminal { + border: solid 4px black; + border-radius: 5px; + scrollbar-color: white black; +} \ No newline at end of file diff --git a/cmdlang/objs.go b/cmdlang/objs.go index 2f5d010..59579a8 100644 --- a/cmdlang/objs.go +++ b/cmdlang/objs.go @@ -276,6 +276,12 @@ func (ia invocationArgs) invokableArg(i int) (invokable, error) { switch v := ia.args[i].(type) { case invokable: return v, nil + case strObject: + iv := ia.ec.lookupInvokable(string(v)) + if iv == nil { + return nil, errors.New("'" + string(v) + "' is not invokable") + } + return iv, nil } return nil, errors.New("expected an invokable arg") }