Pass arguments to main via runtime.process.Init, dispatched on signature
This commit is contained in:
@@ -21,8 +21,8 @@ fn burnStack(depth: usize) u8 {
|
||||
return touch[0] +% burnStack(depth - 1);
|
||||
}
|
||||
|
||||
pub fn main() void {
|
||||
if (runtime.argumentCount() <= 1) {
|
||||
pub fn main(init: runtime.process.Init) void {
|
||||
if (init.arguments.count <= 1) {
|
||||
// First instance: spawn the second with real arguments, then exit.
|
||||
_ = runtime.system.spawnWithArguments("args-echo", &.{ "alpha", "beta-42" });
|
||||
return;
|
||||
@@ -36,8 +36,8 @@ pub fn main() void {
|
||||
const prefix = "args:";
|
||||
@memcpy(buffer[0..prefix.len], prefix);
|
||||
var len: usize = prefix.len;
|
||||
for (0..runtime.argumentCount()) |i| {
|
||||
const argument = runtime.argument(i);
|
||||
var iterator = init.arguments.iterate();
|
||||
while (iterator.next()) |argument| {
|
||||
if (len + 1 + argument.len + 1 > buffer.len) break;
|
||||
buffer[len] = ' ';
|
||||
len += 1;
|
||||
|
||||
Reference in New Issue
Block a user