@@ -89,7 +89,7 @@ module Usage =
8989module Fargo =
9090 let cmd name alt description : Arg < string > =
9191 let usage = { Name = Some name; Alt = Option.ofObj alt; Value = None; Description = description; Help = None; Type = UsageType.Required }
92- let matchusages = { Path = [ usage ]; Options = [ usage ]}
92+ let matchusages = { Path = [ usage ]; Options = []}
9393 let failusages = { Path = []; Options = [ usage]}
9494 let notFound = Error [ $" Command %s {name} not found" ]
9595 { Parse =
@@ -377,7 +377,7 @@ module Fargo =
377377 | Ok x, restx, usagex ->
378378 let argy = f x
379379 let y , resty , usagey = argy.Parse restx
380- y, resty, { Path = usagey.Path @ usagex.Path; Options = usagey.Options}
380+ y, resty, { Path = usagey.Path @ usagex.Path; Options = usagey.Options @ usagex .Options}
381381 | Error ex, restx, usagex ->
382382 Error ex, restx, usagex
383383 Complete =
@@ -386,7 +386,13 @@ module Fargo =
386386 | Ok x, restx, usagex ->
387387 if not ( Tokens.contains pos tokens) || Tokens.contains pos restx then
388388 let argy = f x
389- argy.Complete pos restx
389+ let ( cpx , ix ) = argy.Complete pos restx
390+ let ( cpy , iy ) = arg.Complete pos tokens
391+ match ix, iy with
392+ | false , false -> cpx @ cpy, false
393+ | true , true -> cpx @ cpy, true
394+ | true , false -> cpx, true
395+ | false , true -> cpy, true
390396 else
391397 arg.Complete pos tokens
392398 | Error _, _, _ ->
@@ -544,7 +550,7 @@ module Run =
544550 usages.Options
545551 |> List.filter ( fun u -> not ( u.Name = None || u.IsRequired))
546552
547- if cmds <> [] then printfn " [command]"
553+ if cmds <> [] then printf " [command] "
548554 if opts <> [] then printf " [options] "
549555 for u in args do
550556 if u.IsArg then
@@ -676,7 +682,7 @@ Register-ArgumentCompleter -Native -CommandName %s -ScriptBlock {
676682function __%s _completion
677683 set -l count (commandline -pC)
678684 set -l cmd (commandline -opc)
679- %s complete --position (math $count - (string length $cmd[1])) - 1 "$cmd[2..]"
685+ %s complete --position (math $count - (string length $cmd[1]) - 1) "$cmd[2..]"
680686end
681687complete -f -c %s -a '(__%s _completion)'
682688 """ appName appName appName appName
0 commit comments