mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 15:32:50 -05:00
core/cli: fix keybind provider path override
This commit is contained in:
@@ -34,9 +34,7 @@ var keybindsShowCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
keybindsShowCmd.Flags().String("hyprland-path", "$HOME/.config/hypr", "Path to Hyprland config directory")
|
keybindsShowCmd.Flags().String("path", "", "Override config path for the provider")
|
||||||
keybindsShowCmd.Flags().String("mangowc-path", "$HOME/.config/mango", "Path to MangoWC config directory")
|
|
||||||
keybindsShowCmd.Flags().String("sway-path", "$HOME/.config/sway", "Path to Sway config directory")
|
|
||||||
|
|
||||||
keybindsCmd.AddCommand(keybindsListCmd)
|
keybindsCmd.AddCommand(keybindsListCmd)
|
||||||
keybindsCmd.AddCommand(keybindsShowCmd)
|
keybindsCmd.AddCommand(keybindsShowCmd)
|
||||||
@@ -89,25 +87,34 @@ func runKeybindsList(cmd *cobra.Command, args []string) {
|
|||||||
|
|
||||||
func runKeybindsShow(cmd *cobra.Command, args []string) {
|
func runKeybindsShow(cmd *cobra.Command, args []string) {
|
||||||
providerName := args[0]
|
providerName := args[0]
|
||||||
|
|
||||||
registry := keybinds.GetDefaultRegistry()
|
registry := keybinds.GetDefaultRegistry()
|
||||||
|
|
||||||
if providerName == "hyprland" {
|
customPath, _ := cmd.Flags().GetString("path")
|
||||||
hyprlandPath, _ := cmd.Flags().GetString("hyprland-path")
|
if customPath != "" {
|
||||||
hyprlandProvider := providers.NewHyprlandProvider(hyprlandPath)
|
var provider keybinds.Provider
|
||||||
registry.Register(hyprlandProvider)
|
switch providerName {
|
||||||
}
|
case "hyprland":
|
||||||
|
provider = providers.NewHyprlandProvider(customPath)
|
||||||
|
case "mangowc":
|
||||||
|
provider = providers.NewMangoWCProvider(customPath)
|
||||||
|
case "sway":
|
||||||
|
provider = providers.NewSwayProvider(customPath)
|
||||||
|
default:
|
||||||
|
log.Fatalf("Provider %s does not support custom path", providerName)
|
||||||
|
}
|
||||||
|
|
||||||
if providerName == "mangowc" {
|
sheet, err := provider.GetCheatSheet()
|
||||||
mangowcPath, _ := cmd.Flags().GetString("mangowc-path")
|
if err != nil {
|
||||||
mangowcProvider := providers.NewMangoWCProvider(mangowcPath)
|
log.Fatalf("Error getting cheatsheet: %v", err)
|
||||||
registry.Register(mangowcProvider)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if providerName == "sway" {
|
output, err := json.MarshalIndent(sheet, "", " ")
|
||||||
swayPath, _ := cmd.Flags().GetString("sway-path")
|
if err != nil {
|
||||||
swayProvider := providers.NewSwayProvider(swayPath)
|
log.Fatalf("Error generating JSON: %v", err)
|
||||||
registry.Register(swayProvider)
|
}
|
||||||
|
|
||||||
|
fmt.Fprintln(os.Stdout, string(output))
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
provider, err := registry.Get(providerName)
|
provider, err := registry.Get(providerName)
|
||||||
|
|||||||
Reference in New Issue
Block a user