Skip to content

Commit f25d413

Browse files
committed
Refactor CLI
* eval command replaced with run * run command replaced with exec
1 parent 1813811 commit f25d413

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func main() {
102102

103103
opts = append(opts, risor.WithImporter(newEmbedImporter()))
104104

105-
if len(os.Args) > 1 && os.Args[1] == "run" {
105+
if len(os.Args) > 1 && os.Args[1] == "exec" {
106106
m, err := os.ReadFile("main.risor")
107107
if err != nil {
108108
logger.Fatal("error reading main.risor")
@@ -111,7 +111,7 @@ func main() {
111111
if len(os.Args) > 2 {
112112
ros.SetScriptArgs(append([]string{"main.risor"}, os.Args[2:]...))
113113
}
114-
} else if len(os.Args) > 1 && os.Args[1] == "eval" {
114+
} else if len(os.Args) > 1 && os.Args[1] == "run" {
115115
if len(os.Args) < 3 {
116116
logger.Fatal("missing script argument")
117117
}

main.risor

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,17 @@ cli.app({
178178
args: true,
179179
// This command is handled from the Go side.
180180
// It's here to provide a better help message.
181-
name: "run",
182-
aliases: ["r"],
181+
name: "exec",
182+
aliases: ["x"],
183183
usage: "Run main.risor from the current directory",
184184
}),
185185
cli.command({
186186
args: true,
187187
// This command is handled from the Go side.
188188
// It's here to provide a better help message.
189-
name: "eval",
190-
aliases: ["e"],
191-
usage: "Evaluates a given Risor script",
189+
name: "run",
190+
aliases: ["r"],
191+
usage: "Runs a given Risor script",
192192
}),
193193
cli.command({
194194
args: true,

script/test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
go build
44

5-
./rsx eval tests/tests.risor
5+
./rsx run tests/tests.risor

tests/tests.risor

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ test.with_temp_dir(func(tmp_dir) {
6666
)
6767
cd("test")
6868
test.stdout_equals(
69-
'rsx eval runs main.risor',
70-
'{_rsxbin} eval main.risor',
69+
'rsx run runs main.risor',
70+
'{_rsxbin} run main.risor',
7171
"Hello, World!\n",
7272
)
7373
})
@@ -81,9 +81,9 @@ test.with_temp_dir(func(tmp_dir) {
8181
)
8282
cd("test")
8383
test.raises(
84-
'rsx eval without argument errors',
84+
'rsx run without argument errors',
8585
func() {
86-
exec(_rsxbin, ["eval"])
86+
exec(_rsxbin, ["run"])
8787
}, errors.new("exit status 1"))
8888
})
8989

@@ -96,8 +96,8 @@ test.with_temp_dir(func(tmp_dir) {
9696
)
9797
cd("test")
9898
test.stdout_equals(
99-
'rsx run runs main.risor',
100-
'{_rsxbin} run',
99+
'rsx exec runs main.risor',
100+
'{_rsxbin} exec',
101101
"Hello, World!\n",
102102
)
103103
})
@@ -112,8 +112,8 @@ test.with_temp_dir(func(tmp_dir) {
112112
f.write("import test; test.main()")
113113

114114
test.stdout_equals(
115-
'rsx eval main.risor includes lib/',
116-
'{_rsxbin} eval main.risor',
115+
'rsx run main.risor includes lib/',
116+
'{_rsxbin} run main.risor',
117117
"Hello, World!\n",
118118
)
119119
})
@@ -125,8 +125,8 @@ test.with_temp_dir(func(tmp_dir) {
125125
f.write("import rsx")
126126

127127
test.stdout_equals(
128-
'rsx eval main.risor imports built-in rsx',
129-
'{_rsxbin} eval main.risor',
128+
'rsx run main.risor imports built-in rsx',
129+
'{_rsxbin} run main.risor',
130130
'',
131131
)
132132
})

0 commit comments

Comments
 (0)