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
fixup
  • Loading branch information
f0ssel committed May 24, 2022
commit 0b6480ba074722562e39c36b4abd464ccf49ae80
8 changes: 4 additions & 4 deletions cli/dotfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ func dotfiles() *cobra.Command {
}
_, _ = fmt.Fprintln(cmd.OutOrStdout(), string(out))

// check for install scripts
files, err := os.ReadDir(dotfilesDir)
if err != nil {
return xerrors.Errorf("reading files in dir %s: %w", dotfilesDir, err)
Expand Down Expand Up @@ -154,7 +153,6 @@ func dotfiles() *cobra.Command {
return nil
}

// run found install scripts
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: fmt.Sprintf("Running install script %s.\n\n Continue?", script),
IsConfirm: true,
Expand Down Expand Up @@ -186,6 +184,7 @@ func dotfiles() *cobra.Command {
return cmd
}

// dirExists checks if the dir already exists.
func dirExists(name string) (bool, error) {
_, err := os.Stat(name)
if err != nil {
Expand All @@ -199,8 +198,9 @@ func dirExists(name string) (bool, error) {
return true, nil
}

func findScript(installScriptSet []string, files []fs.DirEntry) string {
for _, i := range installScriptSet {
// findScript will find the first file that matches the script set.
func findScript(scriptSet []string, files []fs.DirEntry) string {
for _, i := range scriptSet {
for _, f := range files {
if f.Name() == i {
return f.Name()
Expand Down