Skip to content

Commit

Permalink
switch from program to interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsdev committed Jul 20, 2023
1 parent d38256f commit dc8ab6a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions internal/document/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ func (b *CodeBlock) Cwd() string {
return b.Attributes()["cwd"]
}

func (b *CodeBlock) Program() string {
return b.Attributes()["program"]
func (b *CodeBlock) Interpreter() string {
return b.Attributes()["interpreter"]
}

func (b *CodeBlock) PromptEnv() bool {
Expand Down
4 changes: 2 additions & 2 deletions internal/runner/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ func GetCellProgram(languageID string, customShell string, cell *document.CodeBl
commandMode = CommandModeTempFile
}

if manualProgram := cell.GetBlock().Program(); manualProgram != "" {
program = manualProgram
if interpreter := cell.GetBlock().Interpreter(); interpreter != "" {
program = interpreter
}

return
Expand Down
8 changes: 4 additions & 4 deletions testdata/script/basic.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ It can even run scripting languages:
console.log("Hello, runme, from javascript!")
```

And it can even run a cell with a custom program:
And it can even run a cell with a custom interpreter:

```js { name=hello-js-cat program=cat }
```js { name=hello-js-cat interpreter=cat }
console.log("Hello, runme, from javascript!")
```

Expand Down Expand Up @@ -135,7 +135,7 @@ func main() {
NAME FILE FIRST COMMAND DESCRIPTION
echo README.md echo "Hello, runme!" With {name=hello} you can annotate it and give it a nice name.
hello-js README.md console.log("Hello, runme, from javascript!") It can even run scripting languages.
hello-js-cat README.md console.log("Hello, runme, from javascript!") And it can even run a cell with a custom program.
hello-js-cat README.md console.log("Hello, runme, from javascript!") And it can even run a cell with a custom interpreter.
-- golden-list-allow-unnamed.txt --
NAME FILE FIRST COMMAND DESCRIPTION
echo-hello README.md echo "Hello, runme!" This is a basic snippet with shell command.
Expand All @@ -145,6 +145,6 @@ echo README.md echo "Hello, runme!" With {name=hello} you can annotate it and gi
echo-1 README.md echo "1" It can contain multiple lines too.
echo-hello-3 README.md echo "Hello, runme! Again!" Also, the dollar sign is not needed.
hello-js README.md console.log("Hello, runme, from javascript!") It can even run scripting languages.
hello-js-cat README.md console.log("Hello, runme, from javascript!") And it can even run a cell with a custom program.
hello-js-cat README.md console.log("Hello, runme, from javascript!") And it can even run a cell with a custom interpreter.
tempdir README.md temp_dir=$(mktemp -d -t "runme-XXXXXXX") It works with cd, pushd, and similar because all lines are executed as a single script.
package-main README.md package main It can also execute a snippet of Go code.

0 comments on commit dc8ab6a

Please sign in to comment.