From 1ea97c288e18397ee937bdd560c6a3223d1a801f Mon Sep 17 00:00:00 2001 From: William Carroll Date: Fri, 25 Nov 2022 09:47:01 -0800 Subject: fix(tools/mg): Support applying args to mg run (empty-target) With this, we can disambiguate the following `mg run` invocations: ```shell $ mg run :foo # run the virtual target, foo, with no args $ mg run -- :foo # run the empty target and pass the arg, :foo, to it ``` Change-Id: Id6395b36a4d8ef3f325937e322e1c27b8630b556 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7408 Tested-by: BuildkiteCI Reviewed-by: tazjin Reviewed-by: sterni --- tools/magrathea/mg.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/magrathea/mg.scm b/tools/magrathea/mg.scm index 4a2a5ca6ded9..f3a615f81890 100644 --- a/tools/magrathea/mg.scm +++ b/tools/magrathea/mg.scm @@ -21,6 +21,7 @@ (define usage #< [] + mg run [] [-- ] target: a target specification with meaning inside of the repository. can @@ -333,9 +334,10 @@ if you meant to pass these arguments to nix, please separate them with (define (run args) (match args [() (execute-run (empty-target))] + [("--" . rest) (execute-run (empty-target) rest)] + [(target . ("--" . rest)) (execute-run (guarantee-success (parse-target target)) rest)] ;; TODO(sterni): flag for selecting binary name - [other (execute-run (guarantee-success (parse-target (car args))) - (cdr args))])) + [_ (mg-error "usage: mg run [] [-- ] (hint: use \"--\" to separate the `mg run []` invocation from the arguments you're passing to the built executable)")])) (define (path args) (match args -- cgit 1.4.1