@@ -24,7 +24,8 @@ import (
2424
2525func vcpkgCmd () * cli.Command {
2626 settings := struct {
27- Output string
27+ Output string
28+ Overlays []string
2829 }{}
2930
3031 return & cli.Command {
@@ -37,20 +38,35 @@ func vcpkgCmd() *cli.Command {
3738 Usage : "output results to file" ,
3839 Destination : & settings .Output ,
3940 },
41+ & cli.StringSliceFlag {
42+ Name : "overlay" ,
43+ Usage : "overlay repositories" ,
44+ Destination : & settings .Overlays ,
45+ },
4046 },
4147 Action : func (c context.Context , cmd * cli.Command ) error {
4248 if cmd .NArg () > 1 {
4349 return fmt .Errorf ("command takes one optional argument <vcpkg-path>: %w" , ErrCli )
4450 }
4551
52+ // Determine working directory
53+ workingDir , err := os .Getwd ()
54+ logrus .WithField ("working-directory" , workingDir ).Debug ("root" )
55+ if err != nil {
56+ return fmt .Errorf ("could not determine working directory: %w" , ErrCli )
57+ }
58+
59+ // Determine overlay directories
60+ for i , overlay := range settings .Overlays {
61+ if ! filepath .IsAbs (overlay ) {
62+ settings .Overlays [i ] = filepath .Join (workingDir , overlay )
63+ }
64+ logrus .WithField (fmt .Sprintf ("overlay[%d]" , i ), settings .Overlays [i ]).Debug ("path" )
65+ }
66+
4667 // Determine vcpkg directory
4768 vcpkgPath := cmd .Args ().Get (0 )
4869 if ! filepath .IsAbs (vcpkgPath ) {
49- workingDir , err := os .Getwd ()
50- logrus .WithField ("working-directory" , workingDir ).Debug ("root" )
51- if err != nil {
52- return fmt .Errorf ("could not determine working directory: %w" , ErrCli )
53- }
5470 vcpkgPath = filepath .Join (workingDir , vcpkgPath )
5571 }
5672
@@ -103,7 +119,7 @@ func vcpkgCmd() *cli.Command {
103119 upgrade := make ([]releaseUpdate , 0 )
104120
105121 for name , library := range cfg .Libraries {
106- semVersion , err := readVcpkgVersion (vcpkgPath , name )
122+ semVersion , err := readVcpkgVersion (settings . Overlays , vcpkgPath , name )
107123 if err != nil {
108124 return fmt .Errorf ("could not find version for %s: %w" , name , err )
109125 }
@@ -187,10 +203,20 @@ func vcpkgCmd() *cli.Command {
187203
188204const configFileName = ".reqcheck.yml"
189205
190- func readVcpkgVersion (vcpkgPath , name string ) (* semver.Version , error ) {
191- file , err := os .ReadFile (filepath .Join (vcpkgPath , "ports" , name , "vcpkg.json" ))
192- if err != nil {
193- return nil , fmt .Errorf ("could not read %s config file: %w" , name , err )
206+ func readVcpkgVersion (overlayPaths []string , vcpkgPath , name string ) (* semver.Version , error ) {
207+ var file []byte
208+ var err error
209+ overlayPaths = append (overlayPaths , vcpkgPath )
210+
211+ for _ , path := range overlayPaths {
212+ file , err = os .ReadFile (filepath .Join (path , "ports" , name , "vcpkg.json" ))
213+ if err == nil {
214+ break
215+ }
216+ }
217+
218+ if file == nil {
219+ return nil , fmt .Errorf ("could not find config file for %s: %w" , name , os .ErrNotExist )
194220 }
195221
196222 un := make (map [interface {}]interface {})
0 commit comments