47 lines
900 B
Go
47 lines
900 B
Go
|
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")
|
||
|
}
|
||
|
|
||
|
|