-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2058 from rsteube/add-pacman-conf
added pacman-conf
- Loading branch information
Showing
4 changed files
with
58 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/rsteube/carapace" | ||
"github.com/rsteube/carapace-bin/pkg/actions/tools/pacman" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "pacman-conf", | ||
Short: "query pacman's configuration file", | ||
Long: "https://man.archlinux.org/man/pacman-conf.8.en", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
rootCmd.Flags().StringP("config", "c", "", "set an alternate configuration file") | ||
rootCmd.Flags().BoolP("help", "h", false, "display this help information") | ||
rootCmd.Flags().StringP("repo", "r", "", "query options for a specific repo") | ||
rootCmd.Flags().BoolP("repo-list", "l", false, "list configured repositories") | ||
rootCmd.Flags().BoolP("verbose", "v", false, "always show directive names") | ||
rootCmd.Flags().BoolP("version", "V", false, "display version information") | ||
|
||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ | ||
"config": carapace.ActionFiles(), | ||
"repo": pacman.ActionRepositories(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package main | ||
|
||
import "github.com/rsteube/carapace-bin/completers/pacman-conf_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package pacman | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/rsteube/carapace" | ||
) | ||
|
||
// ActionRepositories completes package repositories | ||
// | ||
// extra | ||
// multilib | ||
func ActionRepositories() carapace.Action { | ||
return carapace.ActionExecCommand("pacman-conf", "--repo-list")(func(output []byte) carapace.Action { | ||
lines := strings.Split(string(output), "\n") | ||
return carapace.ActionValues(lines[:len(lines)-1]...) | ||
}) | ||
} |