hyprman/cmd/root.go

47 lines
900 B
Go
Raw Normal View History

2024-05-21 15:41:20 -05:00
package cmd
import (
"os"
cc "github.com/ivanpirog/coloredcobra"
"git.dayl.in/daylin/hyprman/internal"
"github.com/spf13/cobra"
)
func Execute() {
cc.Init(&cc.Config{
RootCmd: rootCmd,
Headings: cc.HiMagenta + cc.Bold,
Commands: cc.Bold,
Example: cc.Italic,
ExecName: cc.Bold,
Flags: cc.Bold,
NoExtraNewlines: true,
NoBottomNewline: true,
})
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
var configPath string
var hm = &hyprman.Hyprman{}
var rootCmd = &cobra.Command{
Use: "hyprman",
Short: "hyprland companion app",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
hm.LoadConfig(configPath)
},
}
func init() {
rootCmd.CompletionOptions.HiddenDefaultCmd = true
rootCmd.PersistentFlags().StringVarP(&configPath, "config", "c", hyprman.DefaultConfigPath(), "path to config file")
}