Skip to content

Commit

Permalink
Add files commands
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Jul 3, 2018
1 parent 52c4735 commit 39475ef
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
22 changes: 22 additions & 0 deletions cmd/dots/files.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package main

import (
"fmt"
"strings"

"github.com/spf13/cobra"

"go.evanpurkhiser.com/dots/resolver"
)

var filesCmd = cobra.Command{
Use: "files [filter...]",
Short: "List resolved dotfile paths",
RunE: func(cmd *cobra.Command, args []string) error {
dotfiles := resolver.ResolveDotfiles(*sourceConfig, *sourceLockfile)

fmt.Println(strings.Join(dotfiles.Filter(args).Files(), "\n"))

return nil
},
}
14 changes: 13 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,25 @@ type SourceLockfile struct {
Profile string `json:"profile"`

// Groups is a list of groups to be installed if no profile is specified.
// Does nothing if a profile has been specified.
// Does nothing if a profile has been specified. The base groups from the
// configuration will always be installed.
Groups []string `json:"groups"`

// IntalledFiles is the current list of insatlled configuration files
InstalledFiles []string `json:"installed_files"`
}

// ResolveGroups returns the list of groups the lockfile is currently locked to.
func (l *SourceLockfile) ResolveGroups(config SourceConfig) []string {
profileGroups, ok := config.Profiles[l.Profile]
if ok {
return append(config.BaseGroups, profileGroups...)
}

// Use lockfile groups override list
return append(config.BaseGroups, l.Groups...)
}

// SourceConfigPath determines the location of the source configuration file.
func SourceConfigPath() string {
if path := os.Getenv(sourceConfigEnv); path != "" {
Expand Down

0 comments on commit 39475ef

Please sign in to comment.