Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var CloneCmd = &cobra.Command{ Use: "clone [Git Repo URL]", Short: "Clone dotfiles from Repository", Args: cobra.MinimumNArgs(1), Example: "dona clone https://github.com/user/dotfiles", Run: func(cmd *cobra.Command, args []string) { if err := cloneRepo(args[0]); err != nil { fmt.Println("Failed to clone") os.Exit(1) } fmt.Println("Dotfiles cloned successfully") }, }
View Source
var DelCmd = &cobra.Command{ Use: "del [Git Repo URL/Name]", Short: "Delete a third party dotfile in dots directory", Args: cobra.MinimumNArgs(1), Example: ` dona del user/dotfiles # uri postfix dona del user-dotfiles # folder name `, Run: func(cmd *cobra.Command, args []string) { param := args[0] home, fsErr := GetHome() if fsErr != nil { fmt.Println(fsErr) return } name := strings.Join(strings.Split(param, "/"), "-") path := home + "/.dona/dots/" + name if _, err := os.Stat(path); os.IsNotExist(err) { fmt.Println("🤷 No dotfiles found") return } err := exec.Command("rm", "-rf", path).Run() if err != nil { fmt.Println(err) return } fmt.Println("🧨 Deleted!") }, }
View Source
var GitCmd = &cobra.Command{ Use: "git [args]", Short: "Execute Git commands in your dotfiles", Example: ` dona git status -s dona git revert HEAD dona git remote add origin https://github.com/user/dots `, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { cmd.DisableFlagParsing = true runGit(args) }, }
View Source
var InitCmd = &cobra.Command{ Use: "init", Short: "Initialize your dotfiles", Run: func(cmd *cobra.Command, args []string) { CreateDotsFolders() fmt.Println("Dotfiles initialized") }, }
View Source
var ListCmd = &cobra.Command{ Use: "list dots/pins", Short: "List dotfiles you saved or pins", Args: cobra.MinimumNArgs(1), Example: ` dona list dots dona list pins `, Run: func(cmd *cobra.Command, args []string) { arg := args[0] home, fsErr := GetHome() if fsErr != nil { fmt.Println(fsErr) return } if arg == "dots" { printDots(home) } else if arg == "pins" { file, err := os.ReadFile(home + "/.dona/pins.json") pins := []Pin{} if err != nil { fmt.Println(err) return } if e := json.Unmarshal([]byte(file), &pins); e != nil { fmt.Println(e) return } tags := []string{} for _, pin := range pins { tags = append(tags, pin.Tag) } tags = removeDuplicateValues(tags) fmt.Println(color.YellowString("Pins")) fmt.Println(color.CyanString("│")) for _, tag := range tags { pins := FilterPins(pins, func(pin Pin) bool { return pin.Tag == tag }) fmt.Println(color.CyanString("└── ") + tag) for _, pin := range pins { fmt.Println(color.CyanString("\t└── ") + pin.Name) } } } }, }
View Source
var PinCmd = &cobra.Command{ Use: "pin add/del [Name/url ofo a dotfile]", Short: "Manage your pins (add or delete)", Args: cobra.MinimumNArgs(2), Example: ` dona pin add user/dotfiles -t fedora dona pin del user/dotfiles dona pin del fedora # delete all pins with tag fedora `, Run: func(cmd *cobra.Command, args []string) { tag, error := cmd.Flags().GetString("tag") if error != nil || tag == "" && args[0] == "add" { fmt.Println(color.RedString("Error: ") + "Value for a tag is required") cmd.Help() return } if args[0] != "add" && args[0] != "del" { fmt.Println(color.RedString("Error: ") + "Command not recognized") cmd.Help() return } home, error := GetHome() if error != nil { fmt.Println(error) return } if args[0] == "add" { if error := addPin(home, args); error != nil { fmt.Println(error) } } else { if err := delPin(home, args); err != nil { fmt.Println(err) } } }, }
View Source
var SaveCmd = &cobra.Command{ Use: "save [Git Repo URL/Name]", Short: "Save third party dotfiles in dots directory", Args: cobra.MinimumNArgs(1), Example: ` dona save user/dotfiles # uri postfix dona save https://github.com/user/dots `, Run: func(cmd *cobra.Command, args []string) { param := args[0] w := wow.New(os.Stdout, spin.Get(spin.Earth), " Searching in github") w.Start() home, fsErr := GetHome() if fsErr != nil { fmt.Println(fsErr) return } if isUrl(param) { name := getName(param) fmt.Println(name) err := exec.Command("git", "clone", param, home+"/.dona/dots/"+name).Run() if err != nil { fmt.Println(err) return } } else { url := fmt.Sprintf("https://github.com/%s", param) name := getName(url) err := exec.Command("git", "clone", url, home+"/.dona/dots/"+name).Run() if err != nil { fmt.Println(err) return } } w.PersistWith(spin.Spinner{Frames: []string{"☕"}}, " Enjoy!") }, }
View Source
var SearchCmd = &cobra.Command{ Use: "search [query string]", Short: "Search across dotfiles in github", Long: `Search in github repositories the dotfiles repos with match query`, Args: cobra.MinimumNArgs(1), SuggestFor: []string{ "find", }, Example: ` dona search "arch linux aesthetic" dona search fedora --page 4 dona search cat -p 2 `, Run: func(cmd *cobra.Command, args []string) { page, err := cmd.Flags().GetInt("page") if err != nil { fmt.Println(err) return } result, error := searchDotfiles(args[0], page) if error != nil { fmt.Println(error) return } for _, repo := range result { fmt.Println(color.RedString("Name:"), repo.FullName) fmt.Println(color.BlueString("Url:"), repo.Html_url) fmt.Println(color.YellowString("Description:"), repo.Description) fmt.Println() } }, }
View Source
var ShowVersion bool
View Source
var VersionCmd = &cobra.Command{ Use: "version", Short: "Print the version number of Dona", Long: `All software has versions. This is Dona's`, Run: func(cmd *cobra.Command, args []string) { fmt.Println("Dona version " + GetVersion()) }, }
Functions ¶
func CreateDona ¶
func CreateDona() error
func CreateDotsFolders ¶
func CreateDotsFolders() error
func GetDotfilesPath ¶
func GetVersion ¶
func GetVersion() string
Types ¶
type Repository ¶
type Response ¶
type Response struct { Items []Repository `json:"items"` Total_count int `json:"total_count"` }
Click to show internal directories.
Click to hide internal directories.