Skip to content

Commit

Permalink
added yay
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Jun 27, 2023
1 parent 1199085 commit abd5c41
Show file tree
Hide file tree
Showing 16 changed files with 686 additions and 1 deletion.
2 changes: 1 addition & 1 deletion completers/pacman_completer/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func initUpgradeCmd(cmd *cobra.Command) {

carapace.Gen(cmd).FlagCompletion(carapace.ActionMap{
"arch": carapace.ActionValues("i686", "x86_64"),
"cache-dir": carapace.ActionDirectories(),
"cachedir": carapace.ActionDirectories(),
"color": carapace.ActionValues("auto", "never", "always").StyleF(style.ForKeyword),
"config": carapace.ActionFiles(),
"dbpath": carapace.ActionFiles(),
Expand Down
21 changes: 21 additions & 0 deletions completers/yay_completer/cmd/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var buildCmd = &cobra.Command{
Use: "build",
Aliases: []string{"B"},
Short: "",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(buildCmd).Standalone()

carapace.Gen(buildCmd).PositionalCompletion(
carapace.ActionDirectories(),
)
}
57 changes: 57 additions & 0 deletions completers/yay_completer/cmd/database.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/pacman"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

var databaseCmd = &cobra.Command{
Use: "database",
Aliases: []string{"D"},
Short: "Operate on the package database",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(databaseCmd).Standalone()

databaseCmd.Flags().String("arch", "", "set an alternate architecture")
databaseCmd.Flags().Bool("asdeps", false, "mark packages as non-explicitly installed")
databaseCmd.Flags().Bool("asexplicit", false, "mark packages as explicitly installed")
databaseCmd.Flags().String("cachedir", "", "set an alternate package cache location")
databaseCmd.Flags().CountP("check", "k", "test local database for validity (-kk for sync databases)")
databaseCmd.Flags().String("color", "", "colorize the output")
databaseCmd.Flags().String("config", "", "set an alternate configuration file")
databaseCmd.Flags().Bool("confirm", false, "always ask for confirmation")
databaseCmd.Flags().StringP("dbpath", "b", "", "set an alternate database location")
databaseCmd.Flags().Bool("debug", false, "display debug messages")
databaseCmd.Flags().Bool("disable-download-timeout", false, "use relaxed timeouts for download")
databaseCmd.Flags().String("gpgdir", "", "set an alternate home directory for GnuPG")
databaseCmd.Flags().String("hookdir", "", "set an alternate hook location")
databaseCmd.Flags().String("logfile", "", "set an alternate log file")
databaseCmd.Flags().Bool("noconfirm", false, "do not ask for any confirmation")
databaseCmd.Flags().BoolP("quiet", "q", false, "suppress output of success messages")
databaseCmd.Flags().StringP("root", "r", "", "set an alternate installation root")
databaseCmd.Flags().Bool("sysroot", false, "operate on a mounted guest system (root-only)")
databaseCmd.Flags().BoolP("verbose", "v", false, "be verbose")

carapace.Gen(databaseCmd).FlagCompletion(carapace.ActionMap{
"arch": carapace.ActionValues("i686", "x86_64"),
"cachedir": carapace.ActionDirectories(),
"color": carapace.ActionValues("auto", "never", "always").StyleF(style.ForKeyword),
"config": carapace.ActionFiles(),
"dbpath": carapace.ActionFiles(),
"gpgdir": carapace.ActionDirectories(),
"hookdir": carapace.ActionDirectories(),
"logfile": carapace.ActionFiles(),
"root": carapace.ActionDirectories(),
})

carapace.Gen(databaseCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return pacman.ActionPackages().Invoke(c).Filter(c.Args).ToA()
}),
)
}
53 changes: 53 additions & 0 deletions completers/yay_completer/cmd/deptest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/pacman"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

var deptestCmd = &cobra.Command{
Use: "deptest",
Aliases: []string{"T"},
Short: "Check dependencies",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(deptestCmd).Standalone()

deptestCmd.Flags().String("arch", "", "set an alternate architecture")
deptestCmd.Flags().String("cachedir", "", "set an alternate package cache location")
deptestCmd.Flags().String("color", "", "colorize the output")
deptestCmd.Flags().String("config", "", "set an alternate configuration file")
deptestCmd.Flags().Bool("confirm", false, "always ask for confirmation")
deptestCmd.Flags().StringP("dbpath", "b", "", "set an alternate database location")
deptestCmd.Flags().Bool("debug", false, "display debug messages")
deptestCmd.Flags().Bool("disable-download-timeout", false, "use relaxed timeouts for download")
deptestCmd.Flags().String("gpgdir", "", "set an alternate home directory for GnuPG")
deptestCmd.Flags().String("hookdir", "", "set an alternate hook location")
deptestCmd.Flags().String("logfile", "", "set an alternate log file")
deptestCmd.Flags().Bool("noconfirm", false, "do not ask for any confirmation")
deptestCmd.Flags().StringP("root", "r", "", "set an alternate installation root")
deptestCmd.Flags().Bool("sysroot", false, "operate on a mounted guest system (root-only)")
deptestCmd.Flags().BoolP("verbose", "v", false, "be verbose")

carapace.Gen(deptestCmd).FlagCompletion(carapace.ActionMap{
"arch": carapace.ActionValues("i686", "x86_64"),
"cachedir": carapace.ActionDirectories(),
"color": carapace.ActionValues("auto", "never", "always").StyleF(style.ForKeyword),
"config": carapace.ActionFiles(),
"dbpath": carapace.ActionFiles(),
"gpgdir": carapace.ActionDirectories(),
"hookdir": carapace.ActionDirectories(),
"logfile": carapace.ActionFiles(),
"root": carapace.ActionDirectories(),
})

carapace.Gen(deptestCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return pacman.ActionPackages().Invoke(c).Filter(c.Args).ToA()
}),
)
}
58 changes: 58 additions & 0 deletions completers/yay_completer/cmd/files.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/pacman"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

var filesCmd = &cobra.Command{
Use: "files",
Aliases: []string{"F"},
Short: "Query the files database",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(filesCmd).Standalone()

filesCmd.Flags().String("arch", "", "set an alternate architecture")
filesCmd.Flags().String("cachedir", "", "set an alternate package cache location")
filesCmd.Flags().String("color", "", "colorize the output")
filesCmd.Flags().String("config", "", "set an alternate configuration file")
filesCmd.Flags().Bool("confirm", false, "always ask for confirmation")
filesCmd.Flags().StringP("dbpath", "b", "", "set an alternate database location")
filesCmd.Flags().Bool("debug", false, "display debug messages")
filesCmd.Flags().Bool("disable-download-timeout", false, "use relaxed timeouts for download")
filesCmd.Flags().String("gpgdir", "", "set an alternate home directory for GnuPG")
filesCmd.Flags().String("hookdir", "", "set an alternate hook location")
filesCmd.Flags().BoolP("list", "l", false, "list the files owned by the queried package")
filesCmd.Flags().String("logfile", "", "set an alternate log file")
filesCmd.Flags().Bool("machinereadable", false, "produce machine-readable output")
filesCmd.Flags().Bool("noconfirm", false, "do not ask for any confirmation")
filesCmd.Flags().BoolP("quiet", "q", false, "show less information for query and search")
filesCmd.Flags().CountP("refresh", "y", "download fresh package databases from the server")
filesCmd.Flags().BoolP("regex", "x", false, "enable searching using regular expressions")
filesCmd.Flags().StringP("root", "r", "", "set an alternate installation root")
filesCmd.Flags().Bool("sysroot", false, "operate on a mounted guest system (root-only)")
filesCmd.Flags().BoolP("verbose", "v", false, "be verbose")

carapace.Gen(filesCmd).FlagCompletion(carapace.ActionMap{
"arch": carapace.ActionValues("i686", "x86_64"),
"cachedir": carapace.ActionDirectories(),
"color": carapace.ActionValues("auto", "never", "always").StyleF(style.ForKeyword),
"config": carapace.ActionFiles(),
"dbpath": carapace.ActionFiles(),
"gpgdir": carapace.ActionDirectories(),
"hookdir": carapace.ActionDirectories(),
"logfile": carapace.ActionFiles(),
"root": carapace.ActionDirectories(),
})

carapace.Gen(filesCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return pacman.ActionPackages().Invoke(c).Filter(c.Args).ToA()
}),
)
}
27 changes: 27 additions & 0 deletions completers/yay_completer/cmd/getpkgbuild.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/pacman"
"github.com/spf13/cobra"
)

var getpkgbuildCmd = &cobra.Command{
Use: "getpkgbuild",
Aliases: []string{"G"},
Short: "",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(getpkgbuildCmd).Standalone()

getpkgbuildCmd.Flags().BoolP("-f", "--force", false, "Force download for existing ABS packages")
getpkgbuildCmd.Flags().BoolP("-p", "--print", false, "Print pkgbuild of packages")

carapace.Gen(getpkgbuildCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return pacman.ActionPackageSearch().Invoke(c).Filter(c.Args).ToA()
}),
)
}
73 changes: 73 additions & 0 deletions completers/yay_completer/cmd/query.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/pacman"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

var queryCmd = &cobra.Command{
Use: "query",
Aliases: []string{"Q"},
Short: "Query the package database",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(queryCmd).Standalone()

queryCmd.Flags().String("arch", "", "set an alternate architecture")
queryCmd.Flags().String("cachedir", "", "set an alternate package cache location")
queryCmd.Flags().BoolP("changelog", "c", false, "view the changelog of a package")
queryCmd.Flags().CountP("check", "k", "check that package files exist (-kk for file properties)")
queryCmd.Flags().String("color", "", "colorize the output")
queryCmd.Flags().String("config", "", "set an alternate configuration file")
queryCmd.Flags().Bool("confirm", false, "always ask for confirmation")
queryCmd.Flags().StringP("dbpath", "b", "", "set an alternate database location")
queryCmd.Flags().Bool("debug", false, "display debug messages")
queryCmd.Flags().BoolP("deps", "d", false, "list packages installed as dependencies [filter]")
queryCmd.Flags().Bool("disable-download-timeout", false, "use relaxed timeouts for download")
queryCmd.Flags().BoolP("explicit", "e", false, "list packages explicitly installed [filter]")
queryCmd.Flags().StringP("file", "p", "", "query a package file instead of the database")
queryCmd.Flags().BoolP("foreign", "m", false, "list installed packages not found in sync db(s) [filter]")
queryCmd.Flags().String("gpgdir", "", "set an alternate home directory for GnuPG")
queryCmd.Flags().BoolP("groups", "g", false, "view all members of a package group")
queryCmd.Flags().String("hookdir", "", "set an alternate hook location")
queryCmd.Flags().CountP("info", "i", "view package information (-ii for backup files)")
queryCmd.Flags().BoolP("list", "l", false, "list the files owned by the queried package")
queryCmd.Flags().String("logfile", "", "set an alternate log file")
queryCmd.Flags().BoolP("native", "n", false, "list installed packages only found in sync db(s) [filter]")
queryCmd.Flags().Bool("noconfirm", false, "do not ask for any confirmation")
queryCmd.Flags().StringP("owns", "o", "", "query the package that owns <file>")
queryCmd.Flags().BoolP("quiet", "q", false, "show less information for query and search")
queryCmd.Flags().StringP("root", "r", "", "set an alternate installation root")
queryCmd.Flags().StringP("search", "s", "", "search locally-installed packages for matching strings")
queryCmd.Flags().Bool("sysroot", false, "operate on a mounted guest system (root-only)")
queryCmd.Flags().CountP("unrequired", "t", "list packages not (optionally) required by any package")
queryCmd.Flags().BoolP("upgrades", "u", false, "list outdated packages [filter]")
queryCmd.Flags().BoolP("verbose", "v", false, "be verbose")

carapace.Gen(queryCmd).FlagCompletion(carapace.ActionMap{
"arch": carapace.ActionValues("i686", "x86_64"),
"cachedir": carapace.ActionDirectories(),
"color": carapace.ActionValues("auto", "never", "always").StyleF(style.ForKeyword),
"config": carapace.ActionFiles(),
"dbpath": carapace.ActionFiles(),
"file": carapace.ActionFiles(),
"gpgdir": carapace.ActionDirectories(),
"hookdir": carapace.ActionDirectories(),
"logfile": carapace.ActionFiles(),
"owns": carapace.ActionFiles(),
"root": carapace.ActionDirectories(),
})

carapace.Gen(queryCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if queryCmd.Flag("file").Changed {
return carapace.ActionFiles()
}
return pacman.ActionPackages().Invoke(c).Filter(c.Args).ToA()
}),
)
}
64 changes: 64 additions & 0 deletions completers/yay_completer/cmd/remove.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/pacman"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

var removeCmd = &cobra.Command{
Use: "remove",
Aliases: []string{"R"},
Short: "Remove packages from the system",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(removeCmd).Standalone()

removeCmd.Flags().String("arch", "", "set an alternate architecture")
removeCmd.Flags().String("assume-installed", "", "add a virtual package to satisfy dependencies")
removeCmd.Flags().String("cachedir", "", "set an alternate package cache location")
removeCmd.Flags().BoolP("cascade", "c", false, "remove packages and all packages that depend on them")
removeCmd.Flags().String("color", "", "colorize the output")
removeCmd.Flags().String("config", "", "set an alternate configuration file")
removeCmd.Flags().Bool("confirm", false, "always ask for confirmation")
removeCmd.Flags().Bool("dbonly", false, "only modify database entries, not package files")
removeCmd.Flags().StringP("dbpath", "b", "", "set an alternate database location")
removeCmd.Flags().Bool("debug", false, "display debug messages")
removeCmd.Flags().Bool("disable-download-timeout", false, "use relaxed timeouts for download")
removeCmd.Flags().String("gpgdir", "", "set an alternate home directory for GnuPG")
removeCmd.Flags().String("hookdir", "", "set an alternate hook location")
removeCmd.Flags().String("logfile", "", "set an alternate log file")
removeCmd.Flags().Bool("noconfirm", false, "do not ask for any confirmation")
removeCmd.Flags().CountP("nodeps", "d", "skip dependency version checks (-dd to skip all checks)")
removeCmd.Flags().Bool("noprogressbar", false, "do not show a progress bar when downloading files")
removeCmd.Flags().BoolP("nosave", "n", false, "remove configuration files")
removeCmd.Flags().Bool("noscriptlet", false, "do not execute the install scriptlet if one exists")
removeCmd.Flags().BoolP("print", "p", false, "print the targets instead of performing the operation")
removeCmd.Flags().String("print-format", "", "specify how the targets should be printed")
removeCmd.Flags().CountP("recursive", "s", "remove unnecessary dependencies")
removeCmd.Flags().StringP("root", "r", "", "set an alternate installation root")
removeCmd.Flags().Bool("sysroot", false, "operate on a mounted guest system (root-only)")
removeCmd.Flags().BoolP("unneeded", "u", false, "remove unneeded packages")
removeCmd.Flags().BoolP("verbose", "v", false, "be verbose")

carapace.Gen(removeCmd).FlagCompletion(carapace.ActionMap{
"arch": carapace.ActionValues("i686", "x86_64"),
"cachedir": carapace.ActionDirectories(),
"color": carapace.ActionValues("auto", "never", "always").StyleF(style.ForKeyword),
"config": carapace.ActionFiles(),
"dbpath": carapace.ActionFiles(),
"gpgdir": carapace.ActionDirectories(),
"hookdir": carapace.ActionDirectories(),
"logfile": carapace.ActionFiles(),
"root": carapace.ActionDirectories(),
})

carapace.Gen(removeCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return pacman.ActionPackages().Invoke(c).Filter(c.Args).ToA()
}),
)
}
Loading

0 comments on commit abd5c41

Please sign in to comment.