From 214cfdaea975f0174ffdc5e99bb0c3c83b876b15 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Sat, 4 Nov 2023 12:20:13 -0600 Subject: [PATCH] Project restructure Moved source files into cmd/ and pkg/ directories --- lmcli.go | 16 ++++++++++++++++ main.go => pkg/cli/cmd.go | 9 +++------ config.go => pkg/cli/config.go | 2 +- openai.go => pkg/cli/openai.go | 2 +- store.go => pkg/cli/store.go | 2 +- util.go => pkg/cli/util.go | 2 +- 6 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 lmcli.go rename main.go => pkg/cli/cmd.go (97%) rename config.go => pkg/cli/config.go (99%) rename openai.go => pkg/cli/openai.go (99%) rename store.go => pkg/cli/store.go (99%) rename util.go => pkg/cli/util.go (98%) diff --git a/lmcli.go b/lmcli.go new file mode 100644 index 0000000..48eee6c --- /dev/null +++ b/lmcli.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "os" + + "git.mlow.ca/mlow/lmcli/pkg/cli" +) + +func main() { + lmcli := cli.NewRootCmd() + if err := lmcli.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/main.go b/pkg/cli/cmd.go similarity index 97% rename from main.go rename to pkg/cli/cmd.go index 6881c00..1d9e874 100644 --- a/main.go +++ b/pkg/cli/cmd.go @@ -1,4 +1,4 @@ -package main +package cli import ( "fmt" @@ -133,10 +133,7 @@ var promptCmd = &cobra.Command{ }, } -func main() { +func NewRootCmd() *cobra.Command { rootCmd.AddCommand(newCmd, promptCmd) - if err := rootCmd.Execute(); err != nil { - fmt.Println(err) - os.Exit(1) - } + return rootCmd; } diff --git a/config.go b/pkg/cli/config.go similarity index 99% rename from config.go rename to pkg/cli/config.go index 71e94a8..21c3ca7 100644 --- a/config.go +++ b/pkg/cli/config.go @@ -1,4 +1,4 @@ -package main +package cli import ( "fmt" diff --git a/openai.go b/pkg/cli/openai.go similarity index 99% rename from openai.go rename to pkg/cli/openai.go index b142de9..4d90bf6 100644 --- a/openai.go +++ b/pkg/cli/openai.go @@ -1,4 +1,4 @@ -package main +package cli import ( "context" diff --git a/store.go b/pkg/cli/store.go similarity index 99% rename from store.go rename to pkg/cli/store.go index 182ae3b..500da1e 100644 --- a/store.go +++ b/pkg/cli/store.go @@ -1,4 +1,4 @@ -package main +package cli import ( "database/sql" diff --git a/util.go b/pkg/cli/util.go similarity index 98% rename from util.go rename to pkg/cli/util.go index 27ce1a1..641449b 100644 --- a/util.go +++ b/pkg/cli/util.go @@ -1,4 +1,4 @@ -package main +package cli import ( "os"