Skip to content

feat: add dotfiles command #1723

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
May 25, 2022
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
f0ssel committed May 24, 2022
commit 675f7e6558eefe89bd47dce23169312629e757f4
8 changes: 4 additions & 4 deletions cli/dotfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ func dotfiles() *cobra.Command {

// if repo exists already do a git pull instead of clone
if dotfilesExists {
_, _ = fmt.Fprint(cmd.OutOrStdout(), fmt.Sprintf("Found dotfiles repository at %s\n", dotfilesDir))
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Found dotfiles repository at %s\n", dotfilesDir)
gitCmdDir = dotfilesDir
subcommands = []string{"pull", "--ff-only"}
promtText = fmt.Sprintf("Pulling latest from %s into directory %s.\n Continue?", gitRepo, dotfilesDir)
} else {
_, _ = fmt.Fprint(cmd.OutOrStdout(), fmt.Sprintf("Did not find dotfiles repository at %s\n", dotfilesDir))
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Did not find dotfiles repository at %s\n", dotfilesDir)
}

_, err = cliui.Prompt(cmd, cliui.PromptOptions{
Expand Down Expand Up @@ -122,7 +122,7 @@ func dotfiles() *cobra.Command {
}

for _, s := range scripts {
_, _ = fmt.Fprint(cmd.OutOrStdout(), fmt.Sprintf("\nRunning %s...\n", s))
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "\nRunning %s...\n", s)
// it is safe to use a variable command here because it's from
// a filtered list of pre-approved install scripts
// nolint:gosec
Expand Down Expand Up @@ -158,7 +158,7 @@ func dotfiles() *cobra.Command {
for _, df := range dotfiles {
from := filepath.Join(dotfilesDir, df)
to := filepath.Join(home, df)
_, _ = fmt.Fprintf(cmd.OutOrStdout(), fmt.Sprintf("Symlinking %s to %s...\n", from, to))
_, _ = fmt.Fprintf(cmd.OutOrStdout(), "Symlinking %s to %s...\n", from, to)
// if file already exists at destination remove it
// this behavior matches `ln -f`
_, err := os.Lstat(to)
Expand Down