Help us shape the future of Go! Take the 2026 Go Developer Survey

dotfiles

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DotfilesCmd = &cobra.Command{
	Use:   "dotfiles",
	Short: "Manage dotfiles",
	Long:  `This command is used to facilitate the management of private hidden dot files.`,
	Run: func(cmd *cobra.Command, args []string) {
		log.Info("dotfiles called")

		isVerbose, err := cmd.Flags().GetBool("verbose")
		if err != nil {
			log.Error("Failed to parse verbose flag: %s", err)
			return
		}

		log.Verbose(isVerbose, "Configuration values:")
		log.Verbose(isVerbose, "dotfiles.repoPath: %s", viper.GetString("dotfiles.repoPath"))
		log.Verbose(isVerbose, "dotfiles.worktree: %s", viper.GetString("dotfiles.worktree"))
	},
}
View Source
var FetchCmd = &cobra.Command{
	Use:   "fetch",
	Short: "fetch your local bare repository",
	Long:  `This command fetches remote changes to the local bare dot repository.`,
	Run: func(cmd *cobra.Command, args []string) {
		log.Start("Fetching dotfiles")

		repoPath := os.ExpandEnv(viper.GetString("dotfiles.repoPath"))
		if repoPath == "" {
			log.Error("dotfiles.repoPath is not set in the configuration file")
			return
		}

		worktreePath := os.ExpandEnv(viper.GetString("dotfiles.worktree"))
		if worktreePath == "" {
			log.Error("dotfiles.worktree is not set in the configuration file")
			return
		}

		err := repo.FetchBareRepo(repoPath, worktreePath)
		if err != nil {
			log.Error("Failed to fetch dotfiles: %s", err)
			return
		}

		log.Success("Dotfiles fetched successfully")
	},
}
View Source
var SyncCmd = &cobra.Command{
	Use:   "sync",
	Short: "sync your local bear repository",
	Long:  `This command fetches and pulls in remote changes to the local bare dot repository.`,
	Run: func(cmd *cobra.Command, args []string) {
		log.Start("Syncing dotfiles")

		isVerbose := utils.IsVerbose(cmd)

		repoPath := viper.GetString("dotfiles.repoPath")
		if repoPath == "" {
			log.Error("dotfiles.repopath is not set in the configuration file")
			return
		}
		log.Verbose(isVerbose, "dotfiles.repoPath: %s", repoPath)

		worktreePath := viper.GetString("dotfiles.worktree")
		if worktreePath == "" {
			log.Error("dotfiles.worktree is not set in the configuration file")
			return
		}
		log.Verbose(isVerbose, "dotfiles.worktree: %s", worktreePath)

		log.Info("Fetching dotfiles")
		err := repo.FetchBareRepo(repoPath, worktreePath)
		if err != nil {
			log.Error("Failed to fetch dotfiles: %s", err)
			return
		}

		log.Info("Pulling dotfiles with rebase")
		err = repo.PullRebaseBareRepo(repoPath, worktreePath)
		if err != nil {
			log.Error("Failed to pull and rebase dotfiles: %s", err)
			return
		}

		log.Success("Dotfiles synced successfully")
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL