File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ "strings"
6+
7+ "github.com/spf13/cobra"
8+
9+ "go.evanpurkhiser.com/dots/resolver"
10+ )
11+
12+ var filesCmd = cobra.Command {
13+ Use : "files [filter...]" ,
14+ Short : "List resolved dotfile paths" ,
15+ RunE : func (cmd * cobra.Command , args []string ) error {
16+ dotfiles := resolver .ResolveDotfiles (* sourceConfig , * sourceLockfile )
17+
18+ fmt .Println (strings .Join (dotfiles .Filter (args ).Files (), "\n " ))
19+
20+ return nil
21+ },
22+ }
Original file line number Diff line number Diff line change @@ -78,13 +78,25 @@ type SourceLockfile struct {
7878 Profile string `json:"profile"`
7979
8080 // Groups is a list of groups to be installed if no profile is specified.
81- // Does nothing if a profile has been specified.
81+ // Does nothing if a profile has been specified. The base groups from the
82+ // configuration will always be installed.
8283 Groups []string `json:"groups"`
8384
8485 // IntalledFiles is the current list of insatlled configuration files
8586 InstalledFiles []string `json:"installed_files"`
8687}
8788
89+ // ResolveGroups returns the list of groups the lockfile is currently locked to.
90+ func (l * SourceLockfile ) ResolveGroups (config SourceConfig ) []string {
91+ profileGroups , ok := config .Profiles [l .Profile ]
92+ if ok {
93+ return append (config .BaseGroups , profileGroups ... )
94+ }
95+
96+ // Use lockfile groups override list
97+ return append (config .BaseGroups , l .Groups ... )
98+ }
99+
88100// SourceConfigPath determines the location of the source configuration file.
89101func SourceConfigPath () string {
90102 if path := os .Getenv (sourceConfigEnv ); path != "" {
You can’t perform that action at this time.
0 commit comments