This commit is contained in:
pavel 2026-07-08 10:28:32 +02:00
commit 5b65c4c0e4
11 changed files with 4237 additions and 297 deletions

View file

@ -7,45 +7,69 @@ import "core:strconv"
main :: proc() {
args := os.args
if len(args) < 2 {
fmt.println("usage: odin run client/odin -- <port> [workspace]")
fmt.println(" or: odin run client/odin -- --sdl [workspace] [port] [file]")
if len(args) >= 2 && args[1] == "--terminal-selftest" {
if !terminal_selftest() {
os.exit(1)
}
return
}
if args[1] == "--sdl" {
workspace := "."
if len(args) >= 3 {
workspace = args[2]
if len(args) >= 3 && args[1] == "--git-status-selftest" {
if !git_status_selftest(args[2]) {
os.exit(1)
}
port := 0
file := ""
if len(args) >= 4 {
parsed_port, parsed_ok := strconv.parse_int(args[3])
if parsed_ok {
port = int(parsed_port)
} else {
file = args[3]
return
}
if len(args) >= 2 && args[1] == "--git-selftest" {
workspace := "." if len(args) < 3 else args[2]
if !git_panel_selftest(workspace) {
os.exit(1)
}
return
}
// Legacy smoke-test mode: a bare numeric first argument is a daemon port.
if len(args) >= 2 && args[1] != "--sdl" {
if port, is_port := strconv.parse_int(args[1]); is_port {
workspace := "."
if len(args) >= 3 {
workspace = args[2]
}
run_smoke_client(int(port), workspace)
return
}
if len(args) >= 5 {
file = args[4]
}
// SDL editor mode (default). All arguments are optional and positional in
// any order: a directory is the workspace, a number is a daemon port, and
// anything else is a file to open. `--sdl` is accepted for compatibility.
sdl_args := args[1:]
if len(sdl_args) > 0 && sdl_args[0] == "--sdl" {
sdl_args = sdl_args[1:]
}
workspace := ""
port := 0
file := ""
for arg in sdl_args {
if parsed_port, is_port := strconv.parse_int(arg); is_port && port == 0 {
port = int(parsed_port)
} else if os.is_dir(arg) && len(workspace) == 0 {
workspace = arg
} else if len(file) == 0 {
file = arg
} else {
fmt.println("usage: odin run client/odin -- [workspace] [port] [file]")
fmt.println(" or: odin run client/odin -- <port> [workspace] (smoke test)")
return
}
run_sdl_editor(workspace, port, file)
return
}
port, ok := strconv.parse_int(args[1])
if !ok {
fmt.println("invalid port")
return
}
workspace := "."
if len(args) >= 3 {
workspace = args[2]
}
run_sdl_editor(workspace, port, file)
}
run_smoke_client :: proc(port: int, workspace: string) {
run_buffer_smoke()
editor := run_editor_smoke(workspace)
defer editor_destroy(&editor)