From 26b7d8038031f21ea221c4e040e9c7db8cc8bc27 Mon Sep 17 00:00:00 2001 From: refaktor Date: Tue, 15 Oct 2024 12:37:20 +0200 Subject: [PATCH] improvements to cmd and util/ryel script --- .gitignore | 5 ---- evaldo/builtins.go | 24 +++++++++++++++++ runner/buildtemp/main.rye | 57 --------------------------------------- util/ryel.rye | 21 +++++++++++++++ 4 files changed, 45 insertions(+), 62 deletions(-) delete mode 100644 runner/buildtemp/main.rye diff --git a/.gitignore b/.gitignore index e8616da5..4d9fb82d 100644 --- a/.gitignore +++ b/.gitignore @@ -44,10 +44,5 @@ tests/*.html shell_*.rye console_*.rye -<<<<<<< HEAD buildtemp/main.rye *.bson - -======= -buildtemp/main.rye ->>>>>>> 48009d9729854bd7bbbc0a943f839fc579a2943b diff --git a/evaldo/builtins.go b/evaldo/builtins.go index ef717bcc..f01e6047 100644 --- a/evaldo/builtins.go +++ b/evaldo/builtins.go @@ -7949,6 +7949,30 @@ var builtins = map[string]*env.Builtin{ /* Terminal functions .. move to it's own later */ "cmd": { + Argsn: 1, + Doc: "", + Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object { + switch s0 := arg0.(type) { + case env.String: + + r := exec.Command("/bin/bash", "-c", s0.Value) //nolint: gosec + // stdout, stderr := r.Output() + r.Stdout = os.Stdout + r.Stderr = os.Stderr + + err := r.Run() + if err != nil { + fmt.Println("ERROR") + fmt.Println(err) + } + default: + return makeError(ps, "Arg 1 should be String") + } + return nil + }, + }, + + "cmd\\capture": { Argsn: 1, Doc: "", Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object { diff --git a/runner/buildtemp/main.rye b/runner/buildtemp/main.rye deleted file mode 100644 index ed722f65..00000000 --- a/runner/buildtemp/main.rye +++ /dev/null @@ -1,57 +0,0 @@ - -rye .needs { fyne } - -Data: context { - - add!: fn { task } { tasks .add-rows! task } - remove!: fn { idx } { tasks .remove-row! idx + 1 } - check!: fn { idx val } { tasks .update-row! idx + 1 dict [ "done" val ] } - make-spreadsheet!: fn { texts } { .map { ::x [ 0 x ] } |unpack |spreadsheet* { "done" "text" } |ref |change! 'tasks } - - tasks: ref spreadsheet { "done" "text" } { } -} - -rye .args\raw .split "," |Data/make-spreadsheet! - -do\par fyne { - - win: app .window "Adhocest TODO app" - - lst: list - does { length? deref Data/tasks } - does { - idx: hide label "idx" - h-box [ - check "" fn\par { v } current - { Data/check! to-integer idx .text? v , lst .refresh } - label "" - idx - layout-spacer - button-with-icon "" delete-icon fn\par { } current - { Data/remove! to-integer idx .text? , lst .refresh } - ] - } - fn { i box } { - set! box .objects? { chk lbl hdn xo btn } - chk .set-checked 0 <- i <- deref Data/tasks - lbl .set-text 1 <- i <- deref Data/tasks - hdn .set-text to-string i - } - - input: entry - |place-holder! "Add to list here ..." - |on-submitted! fn { x } { - Data/add! [ 0 x ] - input .set-text "" - lst .refresh - } - - cont: border nil input nil nil [ lst ] - - with win { - .resize size 300.0 300.0 , - .set-content cont , - .show-and-run - } -} - diff --git a/util/ryel.rye b/util/ryel.rye index b6c987bb..5ad4e7d9 100644 --- a/util/ryel.rye +++ b/util/ryel.rye @@ -34,7 +34,27 @@ build-ryel: fn { tags } { ; print "Build command: " + command cmd command } + +build-fyne: fn { tags } { + + print-header + + open %ryel.mod + |fix\either + { print "Create rye.mod file and list modules." " nil " } + { .read-all } + |load + |map { .to-string .concat* "b_" } + |join\with " " :modules |print + + cp-embed: either tags = "embed_main" { "cp main.rye %RYE_HOME/runner/buildtemp/. ; " } { "" } + command: join { cp-embed ` a=%PWD ; cd %RYE_HOME-fyne ; fyne release -os android -appID com.refaktorlabs.fynetest1 -icon Icon.png -appVersion 0.0.1 -tags "` + modules + " " + tags `"; cd "%a"` } ; ` delimiter for string is just temporary ... ' conflicts with lit-words and Rebols { } with blocks so this question is open so far + command .replace "%" "$" ::command + ; print "Build command: " + command + cmd command +} + install-ryel: fn { } { print-header print "TODO: Installing Ryel ..." @@ -44,6 +64,7 @@ rye .args -> 0 |fix { "" } :mode rye .args -> 1 |fix { "" } :tags switch mode { + "buildfyne" { build-fyne tags } "build" { build-ryel tags } "install" { install-ryel } }