Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions internal/basics.rye
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ section "Printing functions"
stdout { print 123 } "123" + newline
}
group "prn"
; added: block printing has no trailing space
stdout { print [ 1 2 3 ] } "1 2 3\n"
stdout { print [ 1 ] } "1\n"
stdout { print [] } "\n"
stdout { prn [ 1 2 ] } "1 2"
stdout { prns [ 1 2 ] } "1 2 "
mold\nowrap ?prn
{ { object } }
{
Expand Down
4 changes: 2 additions & 2 deletions internal/cli-parse/test_basic.rye
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ assert\display "integer option provided" {

; Positional argument
assert\display "positional argument" {
( parse-args { "file.txt" } { file: string required } ) -> "_file"
( parse-args { "file.txt" } { file: string required } ) -> "file"
} "file.txt"

; Multiple positional arguments (many)
assert\display "multiple positional arguments" {
length? ( parse-args { "a.txt" "b.txt" "c.txt" } { files: string many } ) -> "_files"
length? ( parse-args { "a.txt" "b.txt" "c.txt" } { files: string many } ) -> "files"
} 3

print ""
24 changes: 23 additions & 1 deletion internal/cli-parse/test_cli_integration.rye
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,29 @@ assert\display "full spec positional value" {
-v|verbose flag
-o|output string
input: string
} ) -> "_input"
} ) -> "input"
} "in.txt"

print ""


assert\display "my test 1" {
; Minimal variant: imgtool convert
spec2: {
program "imgtool"
-v|verbose flag
-q|quality integer optional 85 doc "JPEG quality"
input: string required doc "Input image"
output: string optional "out.jpg" doc "Output image"
}

argv2: { "-v" "-q" 92 "in.png" "out.jpg" }
args2: parse-args argv2 spec2

[ ( args2 -> "verbose" ) ; true
( args2 -> "quality" ) ; 92
( args2 |probe -> "input" ) ; "in.png"
( args2 |probe -> "output" ) ; "out.jpg"
]

} [ "" "" ]
6 changes: 3 additions & 3 deletions internal/cli-parse/test_help.rye
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ assert\display "help contains subcommand" {
contains generate-help {
program "git-like"
subcommand {
init { doc "Initialize repo" }
clone { doc "Clone repo" }
'init { doc "Initialize repo" }
'clone { doc "Clone repo" }
}
} "init"
} true
Expand All @@ -40,7 +40,7 @@ assert\display "help for subcommand" {
'remote {
doc "Manage remotes"
subcommand {
add { doc "Add a remote" }
'add { doc "Add a remote" }
}
}
}
Expand Down
30 changes: 15 additions & 15 deletions internal/cli-parse/test_subcommands.rye
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ print "## Subcommand Tests"

; Basic subcommand
assert\display "basic subcommand" {
( parse-args { init --force } {
( parse-args { init } {
-v|verbose flag
subcommand {
init { -f|force flag doc "Force initialization" }
build { -o|output string doc "Output directory" }
'init { -f|force flag doc "Force initialization" }
'build { -o|output string doc "Output directory" }
}
} ) -> "command"
} ) |probe -> "command"
} "init"

; Subcommand force flag
assert\display "subcommand flag" {
( parse-args { init --force } {
-v|verbose flag
subcommand {
init { -f|force flag }
build { -o|output string }
'init { -f|force flag }
'build { -o|output string }
}
} ) -> "force"
} true
Expand All @@ -28,8 +28,8 @@ assert\display "subcommand with global flag" {
( parse-args { --verbose init } {
-v|verbose flag
subcommand {
init { -f|force flag }
build { -o|output string }
'init { -f|force flag }
'build { -o|output string }
}
} ) -> "verbose"
} true
Expand All @@ -41,11 +41,11 @@ assert\display "nested subcommand" {
'remote {
doc "Manage remotes"
subcommand {
add {
'add {
name: string required doc "Remote name"
url: string required doc "Remote URL"
}
remove {
'remove {
name: string required
}
}
Expand All @@ -60,14 +60,14 @@ assert\display "nested subcommand positional args" {
subcommand {
'remote {
subcommand {
add {
'add {
name: string required
url: string required
}
}
}
}
} ) -> "_name"
} ) |probe -> "name"
} "origin"

; Command path length
Expand All @@ -76,7 +76,7 @@ assert\display "command path length" {
subcommand {
'remote {
subcommand {
add { name: string required url: string required }
'add { name: string required url: string required }
}
}
}
Expand All @@ -88,8 +88,8 @@ assert\display "string subcommand from CLI" {
( parse-args { "init" "--force" } {
-v|verbose flag
subcommand {
init { -f|force flag }
build { -o|output string }
'init { -f|force flag }
'build { -o|output string }
}
} ) -> "command"
} "init"
Expand Down
5 changes: 5 additions & 0 deletions internal/testing_quirks.rye
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,11 @@ assert\display "prns prints with space" {
capture-stdout { prns "hello" }
} "hello "

; added: capture block printing spacing (no trailing space)
assert\display "block print spacing - no trailing space" {
capture-stdout { print [ 1 2 ] }
} "1 2\n"

; ══════════════════════════════════════════════════════════════════════════════
; 30. MATH CONTEXT QUIRKS
; ══════════════════════════════════════════════════════════════════════════════
Expand Down
Loading