added filetree walking

This commit is contained in:
specCon18 2025-03-16 04:56:52 -04:00
parent 345d0b82d7
commit 0f9ceffeff
5 changed files with 103 additions and 0 deletions

0
LICENSE Normal file
View file

72
cmd/root.go Normal file
View file

@ -0,0 +1,72 @@
/*
Copyright © 2025 Steven Carpenter <steven.carpenter@skdevstudios.com>
*/
package cmd
import (
"fmt"
"os"
"io/fs"
"path/filepath"
"github.com/spf13/cobra"
)
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "v2",
Short: "Tooling to make dealing with TODO statements in comments easier to manage.",
Long: `YUNODO redux is a better written version of a tool I wrote for internal use.
This application is a tool that takes comments that start with TODO: and outputs them in a given format.
format for comment is as follows:
<COMMENT_SYMBOL>TODO: P<PRIORITY_VALUE> <COMMENT>
where COMMENT_SYMBOL is your languages comment symbol,
PRIORITY_VALUE is a priority from 0-9 where 9 is least critical and 0 is needs patched NOW!!!,
and PATH_TO_PROJECT is the path to your codebase's root.
Usage:
yunodo -p <PATH_TO_PROJECT>
`,
// Uncomment the following line if your bare application
// has an action associated with it:
Run: func(cmd *cobra.Command, args []string) {
path, _ := cmd.Flags().GetString("path")
if path != "" {
//TODO: recursivly read each file in the path and store content as string in slice
readFileTree(path)
} else {
fmt.Println("ERROR: No path provided, please provide path using the -p flag")
os.Exit(1)
}
},
}
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
rootCmd.PersistentFlags().StringP("path", "p", "","assign the path to get comments from.")
}
func readFileTree(path string){
var count int
fsys := os.DirFS(path)
fs.WalkDir(fsys, ".", func(p string, d fs.DirEntry, err error) error {
if filepath.Ext(p) == ".go" {
//TODO:add case statement to check for C style comments i.e. // and /* as well as luas -- and other langs #
}
return nil
})
fmt.Println(count)
}

10
go.mod Normal file
View file

@ -0,0 +1,10 @@
module speccon18/yunodo/v2
go 1.23.4
require github.com/spf13/cobra v1.9.1
require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/pflag v1.0.6 // indirect
)

10
go.sum Normal file
View file

@ -0,0 +1,10 @@
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

11
main.go Normal file
View file

@ -0,0 +1,11 @@
/*
Copyright © 2025 Steven Carpenter <steven.carpenter@skdevstudios.com>
*/
package main
import "speccon18/yunodo/v2/cmd"
func main() {
cmd.Execute()
}