Skip to content

Commit e3e0528

Browse files
committed
fix(cli): use :init.get_plain_arguments directly, drop ADO_ARGS workaround
Burrito's Zig wrapper passes CLI args via native argv after -extra, so :init.get_plain_arguments/0 returns them correctly with internal whitespace preserved. The earlier ADO_ARGS env-var workaround (which relied on String.split/2) was both unnecessary and lossy — env vars are null-terminated C strings, so they can't carry args with spaces losslessly. Companion to deps/burrito commit removing the ADO_ARGS env-var write from the Zig launcher. Verified end-to-end: - escript: 'ado prs diff "Employee Management" ...' parses correctly - Burrito binary: same command parses correctly with whitespace in project name intact - All 367 tests pass; Credo clean
1 parent 01e53c7 commit e3e0528

2 files changed

Lines changed: 12 additions & 18 deletions

File tree

lib/ado_cli/application.ex

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,11 @@ defmodule AdoCli.Application do
1616

1717
{:ok, _pid} = Supervisor.start_link(children, strategy: :one_for_one)
1818

19-
# Burrito passes CLI args via ADO_ARGS env var (set by Zig wrapper).
20-
# Falls back to System.argv() for escript/release boot.
21-
args =
22-
case System.get_env("ADO_ARGS") do
23-
nil -> System.argv()
24-
"" -> System.argv()
25-
str -> String.split(str, " ")
26-
end
19+
# Burrito's Zig wrapper passes CLI args via native argv after `-extra`,
20+
# so :init.get_plain_arguments/0 returns them directly with whitespace
21+
# preserved (e.g. "Employee Management" stays intact as one token).
22+
args = Enum.map(:init.get_plain_arguments(), &to_string/1)
2723

28-
# CliMate.CLI run/1 handles exit codes internally via System.halt(0)/halt(1).
29-
# The exit code propagates to the Zig wrapper through the OS process exit.
3024
AdoCli.CLI.run(args)
3125

3226
# Unreachable — CliMate always halts after execution.

lib/ado_cli/cli.ex

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,18 @@ defmodule AdoCli.CLI do
127127
def main(args \\ nil) do
128128
start_finch()
129129

130-
# Burrito passes CLI args via ADO_ARGS env var (set by Zig wrapper).
131-
# System.argv() in Burrito mode includes BEAM flags; prefer env var.
132-
cli_args =
133-
case System.get_env("ADO_ARGS") do
134-
nil -> args || System.argv()
135-
"" -> args || System.argv()
136-
str -> String.split(str, " ")
137-
end
130+
# Burrito's Zig wrapper passes CLI args via native argv after `-extra`,
131+
# so :init.get_plain_arguments/0 returns them directly with whitespace
132+
# preserved. System.argv() in escript mode also has the args.
133+
cli_args = args || System.argv() || plain_args()
138134

139135
run(cli_args)
140136
end
141137

138+
defp plain_args do
139+
Enum.map(:init.get_plain_arguments(), &to_string/1)
140+
end
141+
142142
def command_definition, do: @command
143143

144144
@doc """

0 commit comments

Comments
 (0)