shad-go/tools/testtool/commands/list_private_files.go
2023-03-10 15:23:34 +04:00

45 lines
728 B
Go

package commands
import (
"fmt"
"os"
"path/filepath"
"github.com/spf13/cobra"
)
var listPrivateFilesCmd = &cobra.Command{
Use: "list-private-files",
Short: "list private files",
Run: runListPrivateFiles,
}
func init() {
rootCmd.AddCommand(listPrivateFilesCmd)
}
func doListPrivateFiles() error {
cwd, err := os.Getwd()
if err != nil {
return err
}
privateFiles := listPrivateFiles(".")
for _, f := range privateFiles {
rel, err := filepath.Rel(cwd, f)
if err != nil {
return err
}
fmt.Println(rel)
}
return nil
}
func runListPrivateFiles(cmd *cobra.Command, args []string) {
if err := doListPrivateFiles(); err != nil {
fmt.Fprintf(os.Stderr, "testtool: %v\n", err)
os.Exit(1)
}
}