mirror of
https://github.com/vee1e/gittuf.git
synced 2026-09-03 19:27:07 +00:00
This commit adds support for persistent cache searching as well as explicit populating. Signed-off-by: Aditya Sirish <aditya@saky.in>
37 lines
712 B
Go
37 lines
712 B
Go
// Copyright The gittuf Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package populatecache
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gittuf/gittuf/experimental/gittuf"
|
|
"github.com/gittuf/gittuf/internal/dev"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type options struct{}
|
|
|
|
func (o *options) AddFlags(_ *cobra.Command) {}
|
|
|
|
func (o *options) Run(_ *cobra.Command, _ []string) error {
|
|
repo, err := gittuf.LoadRepository()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return repo.PopulateCache()
|
|
}
|
|
|
|
func New() *cobra.Command {
|
|
o := &options{}
|
|
cmd := &cobra.Command{
|
|
Use: "populate-cache",
|
|
Short: fmt.Sprintf("Populate persistent cache (developer mode only, set %s=1)", dev.DevModeKey),
|
|
RunE: o.Run,
|
|
}
|
|
o.AddFlags(cmd)
|
|
|
|
return cmd
|
|
}
|