spf13--cobra/doc/fs.go
Olivier Robardet 24781b046a
Use afero as underlying FS for manpage generation
It helps softwares using cobra's manpage generation to write tests
2022-04-21 16:46:17 +02:00

24 lines
645 B
Go

package doc
import "github.com/spf13/afero"
// This can be used by any code in current package that need to access filesystem
// It helps softwares using cobra's documentation generation to have better tests
var docFs *afero.Afero
func init() {
// By default, make the docFS a OS one, allowing real FS operations
docFs = &afero.Afero{Fs: afero.NewOsFs()}
}
// GetFS returns the current Afero FS used by the package
// Useful to backup the current FS, before setting a temp FS with SetFS
func GetFS() *afero.Afero {
return docFs
}
// SetFS defines the Afero FS that will be used by the package
func SetFS(fs *afero.Afero) {
docFs = fs
}