From 0f9ceffeff8c3380524e5290b147d51fafcd66f4 Mon Sep 17 00:00:00 2001 From: specCon18 Date: Sun, 16 Mar 2025 04:56:52 -0400 Subject: [PATCH] added filetree walking --- LICENSE | 0 cmd/root.go | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 10 ++++++++ go.sum | 10 ++++++++ main.go | 11 ++++++++ 5 files changed, 103 insertions(+) create mode 100644 LICENSE create mode 100644 cmd/root.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 main.go diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e69de29 diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..8922b35 --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,72 @@ +/* +Copyright © 2025 Steven Carpenter + +*/ +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: + TODO: P + +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 + +`, + // 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) +} + diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..bf4b252 --- /dev/null +++ b/go.mod @@ -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 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ffae55e --- /dev/null +++ b/go.sum @@ -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= diff --git a/main.go b/main.go new file mode 100644 index 0000000..a626bb2 --- /dev/null +++ b/main.go @@ -0,0 +1,11 @@ +/* +Copyright © 2025 Steven Carpenter +*/ + +package main + +import "speccon18/yunodo/v2/cmd" + +func main() { + cmd.Execute() +}