Skip to content

Commit 8a8f418

Browse files
committed
Simplify args: app-only passthrough, always quiet MSBuild
Drop the -- separator and user-facing dotnet publish/run options so trailing tokens always go to the app. Always inject -v:quiet for underlying builds and update docs/tests.
1 parent db636b7 commit 8a8f418

8 files changed

Lines changed: 118 additions & 184 deletions

File tree

readme.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,10 @@ making it optimal for quick iteration and agentic tools authoring and consumptio
2727

2828
```console
2929
# Run a file
30-
dnx go app.cs
30+
dnx go -- app.cs
3131

3232
# Pass arguments to your app
33-
dnx go app.cs -- arg1 arg2
34-
35-
# Pass arguments to the underlying `dotnet publish`
36-
# Args after initial -- are for dotnet publish, after second -- are for your app
37-
dnx go app.cs -- /p:MyProp=true /v:quiet -- arg1 arg2
33+
dnx go -- app.cs arg1 arg2
3834
```
3935

4036
The default mode publishes the app with native AOT and then runs the resulting executable,
@@ -45,7 +41,10 @@ Use `--r2r` when your app needs more dynamic .NET features (reflection, dynamic
4541
that native AOT does not support, while still keeping most publish optimizations:
4642

4743
```console
48-
dnx go app.cs -- --r2r -- arg1 arg2
44+
dnx go -- app.cs --r2r
45+
46+
# Pass arguments to your app
47+
dnx go -- app.cs --r2r arg1 arg2
4948
```
5049

5150
This publishes with `/p:PublishAot=false` and `/p:PublishReadyToRun=true`.
@@ -56,13 +55,10 @@ and runs the app directly from the build output without the optimizations
5655
applied by dotnet to published executables (i.e. AOT, RID-specific optimizations):
5756

5857
```console
59-
dnx go dev -- app.cs
58+
dnx go -- dev app.cs
6059

6160
# Pass arguments to your app
62-
dnx go dev -- app.cs arg1 arg2
63-
64-
# Pass arguments to the underlying `dotnet run`
65-
dnx go dev -- app.cs /p:Configuration=Release -- arg1 arg2
61+
dnx go -- dev app.cs arg1 arg2
6662
```
6763

6864
## Remote references
@@ -106,7 +102,7 @@ Behavior follows the chosen command:
106102
* Default command: downloads (if needed) then `dotnet publish` + execute (AOT by default).
107103
* `dev` command: downloads (if needed) then `dotnet run` for fast iteration.
108104

109-
Arguments after `--` (or all trailing args) are forwarded exactly as with local files.
105+
Trailing arguments are passed to the app, the same as with local files.
110106

111107
## Cache and cleaning
112108

src/Tests/EndToEndTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void Publish_passes_v_q_to_dotnet_and_forwards_app_args()
5757
{
5858
RunGo("clean", app);
5959

60-
var (exit, output) = RunGo(app, "--r2r", "/v:q", "--", "hello", "world");
60+
var (exit, output) = RunGo(app, "--r2r", "hello", "world");
6161
Assert.Equal(0, exit);
6262
Assert.Contains("APP:hello|world", output);
6363
Assert.DoesNotContain("Build started", output);
@@ -108,15 +108,15 @@ public void Remote_ref_default_command_runs_twice_identical_and_uses_dotnet_go()
108108
try
109109
{
110110
// warm-up populate (may emit build logs)
111-
RunGo(remoteRef, "--", "-v:q");
111+
RunGo(remoteRef);
112112

113113
// two runs that should hit cache for identical clean output
114-
var (exit1, output1) = RunGo(remoteRef, "--", "-v:q");
114+
var (exit1, output1) = RunGo(remoteRef);
115115
File.WriteAllText(Path.Combine(scratch, "remote-run1.log"), output1);
116116
Assert.Equal(0, exit1);
117117
Assert.Contains("run.cs", output1);
118118

119-
var (exit2, output2) = RunGo(remoteRef, "--", "-v:q");
119+
var (exit2, output2) = RunGo(remoteRef);
120120
File.WriteAllText(Path.Combine(scratch, "remote-run2.log"), output2);
121121
Assert.Equal(0, exit2);
122122
Assert.Contains("run.cs", output2);
@@ -143,14 +143,14 @@ public void Remote_ref_dev_command_runs_twice_identical_and_uses_dotnet_go()
143143
try
144144
{
145145
// warm-up
146-
RunGo("dev", remoteRef, "--", "-v:q");
146+
RunGo("dev", remoteRef);
147147

148-
var (exit1, output1) = RunGo("dev", remoteRef, "--", "-v:q");
148+
var (exit1, output1) = RunGo("dev", remoteRef);
149149
File.WriteAllText(Path.Combine(scratch, "remote-dev1.log"), output1);
150150
Assert.Equal(0, exit1);
151151
Assert.Contains("run.cs", output1);
152152

153-
var (exit2, output2) = RunGo("dev", remoteRef, "--", "-v:q");
153+
var (exit2, output2) = RunGo("dev", remoteRef);
154154
File.WriteAllText(Path.Combine(scratch, "remote-dev2.log"), output2);
155155
Assert.Equal(0, exit2);
156156
Assert.Contains("run.cs", output2);
@@ -272,7 +272,7 @@ public void Remote_ref_always_revalidates_via_etag_root_dir_touched_source_files
272272
try { RunGo("clean", remoteRef); } catch { }
273273

274274
// Warm-up download
275-
var warm = RunGo(remoteRef, "--", "-v:q");
275+
var warm = RunGo(remoteRef);
276276
Assert.Equal(0, warm.ExitCode);
277277
Assert.Contains("run.cs", warm.Output);
278278

@@ -297,7 +297,7 @@ public void Remote_ref_always_revalidates_via_etag_root_dir_touched_source_files
297297
// Second run (rapid): always performs ETag check; on 304 we touch *only* the root dir,
298298
// individual source files are not touched.
299299
var mtimeBefore = srcInfo.LastWriteTimeUtc;
300-
var (exit2, out2) = RunGo(remoteRef, "--", "-v:q");
300+
var (exit2, out2) = RunGo(remoteRef);
301301
File.WriteAllText(logPath, "SECOND-RUN:\n" + out2);
302302
Assert.Equal(0, exit2);
303303
Assert.Contains("run.cs", out2);
@@ -319,7 +319,7 @@ public void Remote_ref_always_revalidates_via_etag_root_dir_touched_source_files
319319
// Immediate third run: same, no source mtime change.
320320
var mtimeBeforeImm = srcInfo.LastWriteTimeUtc;
321321
var rootBeforeImm = rootInfo.LastWriteTimeUtc;
322-
var (exitImm, outImm) = RunGo(remoteRef, "--", "-v:q");
322+
var (exitImm, outImm) = RunGo(remoteRef);
323323
File.AppendAllText(logPath, "IMMEDIATE:\n" + outImm);
324324
Assert.Equal(0, exitImm);
325325

src/Tests/GoArgsTests.cs

Lines changed: 44 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,6 @@ namespace Tests;
44

55
public class GoArgsTests
66
{
7-
[Fact]
8-
public void Split_without_separator_forwards_all_args_to_app()
9-
{
10-
var (dotnet, app) = GoArgs.Split(["--foo", "bar"]);
11-
12-
Assert.Empty(dotnet);
13-
Assert.Equal(["--foo", "bar"], app);
14-
}
15-
16-
[Fact]
17-
public void Split_with_separator_routes_dotnet_and_app_args()
18-
{
19-
var (dotnet, app) = GoArgs.Split(["-c", "Release", "--", "arg1", "arg2"]);
20-
21-
Assert.Equal(["-c", "Release"], dotnet);
22-
Assert.Equal(["arg1", "arg2"], app);
23-
}
24-
25-
[Fact]
26-
public void Split_with_trailing_separator_leaves_app_args_empty()
27-
{
28-
var (dotnet, app) = GoArgs.Split(["-c", "Release", "--"]);
29-
30-
Assert.Equal(["-c", "Release"], dotnet);
31-
Assert.Empty(app);
32-
}
33-
34-
[Fact]
35-
public void Split_with_leading_separator_leaves_dotnet_args_empty()
36-
{
37-
var (dotnet, app) = GoArgs.Split(["--", "arg1"]);
38-
39-
Assert.Empty(dotnet);
40-
Assert.Equal(["arg1"], app);
41-
}
42-
437
[Fact]
448
public void ApplyPublishMode_adds_r2r_properties_when_enabled()
459
{
@@ -57,28 +21,19 @@ public void ApplyPublishMode_leaves_args_unchanged_when_disabled()
5721
}
5822

5923
[Fact]
60-
public void ApplyDefaultVerbosity_appends_quiet_when_missing()
61-
{
62-
Assert.Equal(["-v:q"], GoArgs.ApplyDefaultVerbosity([]));
63-
Assert.Equal(["-c", "Release", "-v:q"], GoArgs.ApplyDefaultVerbosity(["-c", "Release"]));
64-
}
65-
66-
[Fact]
67-
public void ApplyDefaultVerbosity_leaves_args_unchanged_when_verbosity_present()
24+
public void ApplyVerbosity_always_appends_quiet()
6825
{
69-
Assert.Equal(["-v:q"], GoArgs.ApplyDefaultVerbosity(["-v:q"]));
70-
Assert.Equal(["-v", "q"], GoArgs.ApplyDefaultVerbosity(["-v", "q"]));
71-
Assert.Equal(["--verbosity", "quiet"], GoArgs.ApplyDefaultVerbosity(["--verbosity", "quiet"]));
72-
Assert.Equal(["--verbosity:diag"], GoArgs.ApplyDefaultVerbosity(["--verbosity:diag"]));
73-
Assert.Equal(["/v:q"], GoArgs.ApplyDefaultVerbosity(["/v:q"]));
26+
Assert.Equal(["-v:quiet"], GoArgs.ApplyVerbosity([]));
27+
Assert.Equal(["/p:PublishAot=false", "/p:PublishReadyToRun=true", "-v:quiet"],
28+
GoArgs.ApplyVerbosity(GoArgs.ApplyPublishMode([], readyToRun: true)));
7429
}
7530

7631
[Fact]
7732
public void Normalize_maps_go_prefixed_switches_to_bare_forms()
7833
{
79-
var normalized = GoArgs.Normalize(["--go-debug", "--go-r2r", "owner/repo", "--", "apparg"]);
34+
var normalized = GoArgs.Normalize(["--go-debug", "--go-r2r", "owner/repo", "apparg"]);
8035

81-
Assert.Equal(["--debug", "--r2r", "owner/repo", "--", "apparg"], normalized);
36+
Assert.Equal(["--debug", "--r2r", "owner/repo", "apparg"], normalized);
8237
}
8338

8439
[Fact]
@@ -105,42 +60,34 @@ public void Normalize_empty_and_null()
10560
}
10661

10762
[Fact]
108-
public void PrepareCafArgs_strips_dotnet_args_and_separator_for_default_command()
63+
public void PrepareCafArgs_forwards_all_trailing_tokens_as_app_args()
10964
{
110-
var caf = GoArgs.PrepareCafArgs(["app.cs", "/p:MyProp=true", "--", "arg1", "arg2"]);
65+
var caf = GoArgs.PrepareCafArgs(["app.cs", "/p:MyProp=true", "arg1", "arg2"]);
11166

11267
Assert.Equal(["app.cs"], caf);
113-
Assert.Equal(["/p:MyProp=true", "--", "arg1", "arg2"], GoArgs.ForwardArgs);
114-
115-
var (dotnet, app) = GoArgs.Split(GoArgs.ForwardArgs);
116-
Assert.Equal(["/p:MyProp=true"], dotnet);
117-
Assert.Equal(["arg1", "arg2"], app);
68+
Assert.Equal(["/p:MyProp=true", "arg1", "arg2"], GoArgs.ForwardArgs);
11869
}
11970

12071
[Fact]
121-
public void PrepareCafArgs_strips_msbuild_verbosity_before_separator()
72+
public void PrepareCafArgs_forwards_verbosity_tokens_as_app_args()
12273
{
123-
var caf = GoArgs.PrepareCafArgs(["app.cs", "/v:q", "--", "hello", "world"]);
74+
var caf = GoArgs.PrepareCafArgs(["app.cs", "-v", "n", "hello", "world"]);
12475

12576
Assert.Equal(["app.cs"], caf);
126-
Assert.Equal(["/v:q", "--", "hello", "world"], GoArgs.ForwardArgs);
127-
128-
var (dotnet, app) = GoArgs.Split(GoArgs.ForwardArgs);
129-
Assert.Equal(["/v:q"], dotnet);
130-
Assert.Equal(["hello", "world"], app);
77+
Assert.Equal(["-v", "n", "hello", "world"], GoArgs.ForwardArgs);
13178
}
13279

13380
[Fact]
13481
public void PrepareCafArgs_keeps_go_flags_and_forwards_rest_for_dev()
13582
{
136-
var caf = GoArgs.PrepareCafArgs(["dev", "app.cs", "--r2r", "/p:Configuration=Release", "--", "apparg"]);
83+
var caf = GoArgs.PrepareCafArgs(["dev", "app.cs", "--r2r", "apparg", "/p:x=1"]);
13784

13885
Assert.Equal(["dev", "app.cs", "--r2r"], caf);
139-
Assert.Equal(["/p:Configuration=Release", "--", "apparg"], GoArgs.ForwardArgs);
86+
Assert.Equal(["apparg", "/p:x=1"], GoArgs.ForwardArgs);
14087
}
14188

14289
[Fact]
143-
public void PrepareCafArgs_forwards_positional_args_when_no_separator()
90+
public void PrepareCafArgs_forwards_positional_args_when_no_options()
14491
{
14592
GoArgs.PrepareCafArgs(["app.cs", "arg1", "arg2"]);
14693

@@ -168,9 +115,35 @@ public void PrepareCafArgs_passes_help_through_unchanged()
168115
[Fact]
169116
public void PrepareCafArgs_maps_debug_flag_to_caf_option_name()
170117
{
171-
var caf = GoArgs.PrepareCafArgs(["app.cs", "--debug", "/p:x=1", "--", "apparg"]);
118+
var caf = GoArgs.PrepareCafArgs(["app.cs", "--debug", "apparg"]);
172119

173120
Assert.Equal(["app.cs", "--gdbg"], caf);
174-
Assert.Equal(["/p:x=1", "--", "apparg"], GoArgs.ForwardArgs);
121+
Assert.Equal(["apparg"], GoArgs.ForwardArgs);
122+
}
123+
124+
[Fact]
125+
public void PrepareCafArgs_does_not_split_on_double_dash()
126+
{
127+
// A bare "--" is no longer a dotnet/app separator; it is an app arg if present.
128+
var caf = GoArgs.PrepareCafArgs(["app.cs", "--", "arg1"]);
129+
130+
Assert.Equal(["app.cs"], caf);
131+
Assert.Equal(["--", "arg1"], GoArgs.ForwardArgs);
132+
}
133+
134+
[Fact]
135+
public void BuildDotnetArgs_default_is_quiet_without_r2r()
136+
{
137+
var dotnetArgs = GoArgs.ApplyVerbosity(GoArgs.ApplyPublishMode([], readyToRun: false));
138+
139+
Assert.Equal(["-v:quiet"], dotnetArgs);
140+
}
141+
142+
[Fact]
143+
public void BuildDotnetArgs_with_r2r_is_quiet()
144+
{
145+
var dotnetArgs = GoArgs.ApplyVerbosity(GoArgs.ApplyPublishMode([], readyToRun: true));
146+
147+
Assert.Equal(["/p:PublishAot=false", "/p:PublishReadyToRun=true", "-v:quiet"], dotnetArgs);
175148
}
176-
}
149+
}

0 commit comments

Comments
 (0)