@@ -89,7 +89,7 @@ module Usage =
89
89
module Fargo =
90
90
let cmd name alt description : Arg < string > =
91
91
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 = []}
93
93
let failusages = { Path = []; Options = [ usage]}
94
94
let notFound = Error [ $" Command %s {name} not found" ]
95
95
{ Parse =
@@ -377,7 +377,7 @@ module Fargo =
377
377
| Ok x, restx, usagex ->
378
378
let argy = f x
379
379
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}
381
381
| Error ex, restx, usagex ->
382
382
Error ex, restx, usagex
383
383
Complete =
@@ -386,7 +386,13 @@ module Fargo =
386
386
| Ok x, restx, usagex ->
387
387
if not ( Tokens.contains pos tokens) || Tokens.contains pos restx then
388
388
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
390
396
else
391
397
arg.Complete pos tokens
392
398
| Error _, _, _ ->
@@ -544,7 +550,7 @@ module Run =
544
550
usages.Options
545
551
|> List.filter ( fun u -> not ( u.Name = None || u.IsRequired))
546
552
547
- if cmds <> [] then printfn " [command]"
553
+ if cmds <> [] then printf " [command] "
548
554
if opts <> [] then printf " [options] "
549
555
for u in args do
550
556
if u.IsArg then
@@ -676,7 +682,7 @@ Register-ArgumentCompleter -Native -CommandName %s -ScriptBlock {
676
682
function __%s _completion
677
683
set -l count (commandline -pC)
678
684
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..]"
680
686
end
681
687
complete -f -c %s -a '(__%s _completion)'
682
688
""" appName appName appName appName
0 commit comments