Skip to content

Commit

Permalink
Merge pull request #2152 from rsteube/pamac-integrate-file
Browse files Browse the repository at this point in the history
pamac: integrate file completion
  • Loading branch information
rsteube authored Jan 8, 2024
2 parents 705032f + 1bca3a1 commit 3c160d9
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions completers/pamac_completer/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cmd
import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/pamac"
"github.com/rsteube/carapace/pkg/util"
"github.com/rsteube/carapace/pkg/condition"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -32,15 +32,10 @@ func init() {
})

carapace.Gen(installCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if util.HasPathPrefix(c.Value) {
return carapace.ActionFiles(".pkg", ".pkg.tar.gz", ".pkg.tar.xz", ".pkg.tar.zst")
}

return carapace.Batch(
pamac.ActionPackageGroups(),
pamac.ActionPackageSearch(),
).ToA()
}),
carapace.Batch(
carapace.ActionFiles(".pkg", ".pkg.tar.gz", ".pkg.tar.xz", ".pkg.tar.zst"),
pamac.ActionPackageGroups().Unless(condition.CompletingPath),
pamac.ActionPackageSearch().Unless(condition.CompletingPath),
).ToA(),
)
}

0 comments on commit 3c160d9

Please sign in to comment.