Skip to content

Commit d62e4c1

Browse files
committed
fix(cli): correctly handle running script and repl
1 parent 24d9a29 commit d62e4c1

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## v0.0.19-next
44

55
- fix(lsp): `lithia lsp tcp` didn't work as expected
6+
- fix(cli): correctly handle running script and repl
67

78
## v0.0.18
89

app/lithia/cmd/root.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ var rootCmd = &cobra.Command{
2121
"\n" +
2222
"Lean more at https://github.com/vknabel/lithia",
2323
Version: fmt.Sprintf("%s\ncommit: %s\nbuilt by: %s\nbuilt at: %s", info.Version, info.Commit, info.Date, info.BuiltBy),
24-
Args: cobra.RangeArgs(0, 1),
24+
Args: cobra.MinimumNArgs(0),
2525
Run: func(cmd *cobra.Command, args []string) {
26-
if len(args) == 1 {
27-
runFile(args[0])
26+
if len(args) >= 1 {
27+
runFile(args[0], args)
2828
} else {
2929
runPrompt()
3030
}

app/lithia/cmd/run.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ func init() {
1616
var runCmd = &cobra.Command{
1717
Use: "run [script]",
1818
Short: "Runs a Lithia script",
19-
Args: cobra.ExactArgs(1),
19+
Args: cobra.MinimumNArgs(1),
2020
Run: func(cmd *cobra.Command, args []string) {
21-
runFile(args[0])
21+
runFile(args[0], args)
2222
},
2323
}
2424

25-
func runFile(fileName string) {
25+
func runFile(fileName string, args []string) {
26+
world.Current.Args = args
2627
scriptData, err := world.Current.FS.ReadFile(fileName)
2728
if err != nil {
2829
fmt.Fprint(world.Current.Stderr, err)

0 commit comments

Comments
 (0)