From 66fc781260a3124ebca28e63be43be9595de0eee Mon Sep 17 00:00:00 2001 From: Brian Rogers Date: Tue, 12 May 2026 21:05:03 -0600 Subject: [PATCH] wip: moving things around to logically group them --- cmd/root.go | 7 +++++-- internal/app/main.go | 8 ++++++-- internal/cli/io/list.go | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 internal/cli/io/list.go diff --git a/cmd/root.go b/cmd/root.go index 4a77fbf..8d42daf 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -22,11 +22,14 @@ var rootCmd = &cobra.Command{ var listCmd = &cobra.Command{ Use: "list [directory]", Short: "List the contents of a directory", + Long: "List the contents of a directory. Only shows one level deep.", Args: cobra.MaximumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - name := "world" + + fileStorePath := os.Getenv("STORAGE_PATH") + resolveFileStorePath(fileStorePath) + readFilesFromFileStorePath(fileStorePath) - fmt.Printf("Hello, %s!\n", name) return nil }, } diff --git a/internal/app/main.go b/internal/app/main.go index 307fa72..8ee31b3 100644 --- a/internal/app/main.go +++ b/internal/app/main.go @@ -8,6 +8,8 @@ import ( "path/filepath" "time" + "drogobox.com/drogobox/cmd" + "github.com/joho/godotenv" ) @@ -103,7 +105,7 @@ func main() { log.Fatal("Error loading .env file") } - port := os.Getenv("PORT") + /*port := os.Getenv("PORT") fileStorePath := os.Getenv("STORAGE_PATH") @@ -112,5 +114,7 @@ func main() { fmt.Printf("in the future I will listen on port: %s\n", port) fmt.Printf("Reading files from: %s\n", fileStorePath) - readFilesFromFileStorePath(fileStorePath) + readFilesFromFileStorePath(fileStorePath)*/ + + cmd.Execute() } diff --git a/internal/cli/io/list.go b/internal/cli/io/list.go new file mode 100644 index 0000000..7e95ddb --- /dev/null +++ b/internal/cli/io/list.go @@ -0,0 +1,23 @@ +package cmd + +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +var listCmd = &cobra.Command{ + Use: "list [directory]", + Short: "List the contents of a directory", + Long: "List the contents of a directory. Only shows one level deep.", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + + fileStorePath := os.Getenv("STORAGE_PATH") + resolveFileStorePath(fileStorePath) + readFilesFromFileStorePath(fileStorePath) + + return nil + }, +}