diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..ef03621 --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,124 @@ +package cmd + +import ( + "context" + "fmt" + "log" + "os" + "time" + + "github.com/fatih/color" + "github.com/gwenwindflower/tbd/internal" + "github.com/gwenwindflower/tbd/sourcerer" + "github.com/spf13/cobra" +) + +type Elapsed struct { + DbStart time.Time + ProcessingStart time.Time + DbElapsed float64 + ProcessingElapsed float64 +} + +var ( + greenBold = color.New(color.FgMagenta).Add(color.Bold).SprintFunc() + rootCmd = &cobra.Command{ + Use: "tbd", + Short: "šŸ A sweet and speedy code generator for dbt projects. šŸŽļøāœØ", + Long: fmt.Sprintf(`šŸ %s šŸŽļøāœØ +tbd uses your database schema to generate YAML configs and +SQL staging models, including tests and docs via LLM. + +It's the easy button for starting a dbt project.`, greenBold("A sweet and speedy code generator for dbt projects.")), + Run: func(cmd *cobra.Command, args []string) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + ps, err := internal.FetchDbtProfiles() + if err != nil { + log.Fatalf("Error fetching dbt profiles: %v\n", err) + } + fr, err := internal.Forms(ps) + if err != nil { + log.Fatalf("Error running form: %v\n", err) + } + if !fr.Confirm { + log.Fatal("ā›” User cancelled.") + } + cd := internal.SetConnectionDetails(fr, ps) + + e := Elapsed{} + e.DbStart = time.Now() + + bd := fr.BuildDir + err = internal.PrepBuildDir(bd) + if err != nil { + log.Fatalf("Error preparing build directory: %v\n", err) + } + dbc, err := sourcerer.GetConn(cd) + if err != nil { + log.Fatalf("Error getting database connection: %v\n", err) + } + err = dbc.ConnectToDb(ctx) + if err != nil { + log.Fatalf("Error connecting to database: %v\n", err) + } + fmt.Println("Connected to database") + ts, err := dbc.GetSourceTables(ctx) + if err != nil { + log.Fatalf("Error getting sources: %v\n", err) + } + fmt.Println("Got source tables") + fmt.Println("Putting columns on tables...") + err = sourcerer.PutColumnsOnTables(ctx, ts, dbc) + if err != nil { + log.Fatalf("Error putting columns on tables: %v\n", err) + } + + e.DbElapsed = time.Since(e.DbStart).Seconds() + // End of database interaction, start of processing + e.ProcessingStart = time.Now() + + if fr.GenerateDescriptions { + llm, err := internal.GetLlm(fr) + if err != nil { + // Using Printf instead of log.Fatalf since the program doesn't + // need to totally fail if the API provider can't be fetched + fmt.Printf("Error getting API provider: %v\n", err) + } + fmt.Println("Generating descriptions and tests...") + internal.InferColumnFields(llm, ts) + if err != nil { + // Using Printf instead of log.Fatalf since the program + // doesn't need to totally fail if there's an error in the column field inference + fmt.Printf("Error inferring column fields: %v\n", err) + } + } + fmt.Println("Writing files...") + if fr.CreateProfile { + internal.WriteProfile(cd, bd) + } + if fr.ScaffoldProject { + s, err := internal.WriteScaffoldProject(cd, bd, fr.ProjectName) + if err != nil { + log.Fatalf("Error scaffolding project: %v\n", err) + } + bd = s + } + err = internal.WriteFiles(ts, bd, fr.Prefix) + if err != nil { + log.Fatalf("Error writing files: %v\n", err) + } + e.ProcessingElapsed = time.Since(e.ProcessingStart).Seconds() + pinkUnderline := color.New(color.FgMagenta).Add(color.Bold, color.Underline).SprintFunc() + fmt.Printf("\nšŸ Done in %.1fs fetching data and %.1fs writing files!\nYour YAML and SQL files are in the %s directory.", e.DbElapsed, e.ProcessingElapsed, pinkUnderline(fr.BuildDir)) + }, + } +) + +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..735389e --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,21 @@ +package cmd + +import ( + "fmt" + + "github.com/gwenwindflower/tbd/internal" + "github.com/spf13/cobra" +) + +func init() { + rootCmd.AddCommand(versionCmd) +} + +var versionCmd = &cobra.Command{ + Use: "version", + Short: "Print the version number of tbd", + Long: `Wanna know what version of tbd you're running? Well I've got some great news for you.`, + Run: func(cmd *cobra.Command, args []string) { + fmt.Printf("tbd v%s\n", internal.VERSION) + }, +} diff --git a/go.mod b/go.mod index afc5c6e..85d9c00 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/marcboeker/go-duckdb v1.6.3 github.com/schollz/progressbar/v3 v3.14.2 github.com/snowflakedb/gosnowflake v1.9.0 + github.com/spf13/cobra v1.8.0 google.golang.org/api v0.170.0 gopkg.in/yaml.v2 v2.4.0 ) @@ -80,6 +81,7 @@ require ( github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect github.com/hashicorp/go-cleanhttp v0.5.1 // indirect github.com/hashicorp/go-retryablehttp v0.7.1 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/klauspost/asmfmt v1.3.2 // indirect github.com/klauspost/compress v1.17.7 // indirect @@ -105,6 +107,7 @@ require ( github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/zerolog v1.28.0 // indirect github.com/sirupsen/logrus v1.9.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect github.com/zeebo/xxh3 v1.0.2 // indirect go.opencensus.io v0.24.0 // indirect go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect diff --git a/go.sum b/go.sum index fa9ea69..79dca39 100644 --- a/go.sum +++ b/go.sum @@ -107,6 +107,7 @@ github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:Yyn github.com/coreos/go-oidc/v3 v3.5.0 h1:VxKtbccHZxs8juq7RdJntSqtXFtde9YpNpGn0yqgEHw= github.com/coreos/go-oidc/v3 v3.5.0/go.mod h1:ecXRtV4romGPeO6ieExAsUK9cb/3fp9hXNz1tlv8PIM= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= github.com/databricks/databricks-sql-go v1.5.4 h1:N6dFuWsouupQdN3W5tHQj0vvWfAfA0YBiblMq4h/qqU= @@ -205,6 +206,8 @@ github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxC github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-retryablehttp v0.7.1 h1:sUiuQAnLlbvmExtFQs72iFW/HXeUn8Z1aJLQ4LJJbTQ= github.com/hashicorp/go-retryablehttp v0.7.1/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= @@ -287,13 +290,18 @@ github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUz github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY= github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/schollz/progressbar/v3 v3.14.2 h1:EducH6uNLIWsr560zSV1KrTeUb/wZGAHqyMFIEa99ks= github.com/schollz/progressbar/v3 v3.14.2/go.mod h1:aQAZQnhF4JGFtRJiw/eobaXpsqpVQAftEQ+hLGXaRc4= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/snowflakedb/gosnowflake v1.9.0 h1:s2ZdwFxFfpqwa5CqlhnzRESnLmwU3fED6zyNOJHFBQA= github.com/snowflakedb/gosnowflake v1.9.0/go.mod h1:4ZgHxVf2OKwecx07WjfyAMr0gn8Qj4yvwAo68Og8wsU= +github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0= +github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= diff --git a/fetch_dbt_profiles.go b/internal/fetch_dbt_profiles.go similarity index 99% rename from fetch_dbt_profiles.go rename to internal/fetch_dbt_profiles.go index 7965393..da5e2af 100644 --- a/fetch_dbt_profiles.go +++ b/internal/fetch_dbt_profiles.go @@ -1,4 +1,4 @@ -package main +package internal import ( "log" diff --git a/fetch_dbt_profiles_test.go b/internal/fetch_dbt_profiles_test.go similarity index 98% rename from fetch_dbt_profiles_test.go rename to internal/fetch_dbt_profiles_test.go index 5f0438d..3d4417f 100644 --- a/fetch_dbt_profiles_test.go +++ b/internal/fetch_dbt_profiles_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "os" diff --git a/forms.go b/internal/forms.go similarity index 99% rename from forms.go rename to internal/forms.go index c651900..b039b80 100644 --- a/forms.go +++ b/internal/forms.go @@ -1,4 +1,4 @@ -package main +package internal import ( "errors" @@ -84,7 +84,7 @@ To prepare, make sure you have the following: _See_ %s _for warehouse-specific requirements_: https://github.com/gwenwindflower/tbd -`, greenBold(Version), pinkUnderline("existing dbt profile"), pinkUnderline("connection details"), greenBold("README"))), +`, greenBold(VERSION), pinkUnderline("existing dbt profile"), pinkUnderline("connection details"), greenBold("README"))), ), huh.NewGroup( diff --git a/get_dbt_profile.go b/internal/get_dbt_profile.go similarity index 92% rename from get_dbt_profile.go rename to internal/get_dbt_profile.go index ec1c5f3..5c419a8 100644 --- a/get_dbt_profile.go +++ b/internal/get_dbt_profile.go @@ -1,4 +1,4 @@ -package main +package internal import ( "fmt" diff --git a/get_dbt_profile_test.go b/internal/get_dbt_profile_test.go similarity index 98% rename from get_dbt_profile_test.go rename to internal/get_dbt_profile_test.go index 06538f7..d924bfa 100644 --- a/get_dbt_profile_test.go +++ b/internal/get_dbt_profile_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "os" diff --git a/llm_get_llm.go b/internal/llm_get_llm.go similarity index 99% rename from llm_get_llm.go rename to internal/llm_get_llm.go index d07f7b2..637b223 100644 --- a/llm_get_llm.go +++ b/internal/llm_get_llm.go @@ -1,4 +1,4 @@ -package main +package internal import ( "fmt" diff --git a/llm_get_rate_limiter.go b/internal/llm_get_rate_limiter.go similarity index 97% rename from llm_get_rate_limiter.go rename to internal/llm_get_rate_limiter.go index c68245e..16fa58d 100644 --- a/llm_get_rate_limiter.go +++ b/internal/llm_get_rate_limiter.go @@ -1,4 +1,4 @@ -package main +package internal import "time" diff --git a/llm_get_response.go b/internal/llm_get_response.go similarity index 99% rename from llm_get_response.go rename to internal/llm_get_response.go index 744711f..38e8bd8 100644 --- a/llm_get_response.go +++ b/internal/llm_get_response.go @@ -1,4 +1,4 @@ -package main +package internal import ( "bytes" diff --git a/llm_get_response_test.go b/internal/llm_get_response_test.go similarity index 99% rename from llm_get_response_test.go rename to internal/llm_get_response_test.go index 652c5ec..e682230 100644 --- a/llm_get_response_test.go +++ b/internal/llm_get_response_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "fmt" diff --git a/llm_infer_column_fields.go b/internal/llm_infer_column_fields.go similarity index 98% rename from llm_infer_column_fields.go rename to internal/llm_infer_column_fields.go index d50b6ea..d92e5cb 100644 --- a/llm_infer_column_fields.go +++ b/internal/llm_infer_column_fields.go @@ -1,4 +1,4 @@ -package main +package internal import ( "fmt" diff --git a/llm_infer_column_fields_test.go b/internal/llm_infer_column_fields_test.go similarity index 98% rename from llm_infer_column_fields_test.go rename to internal/llm_infer_column_fields_test.go index 6005bd4..46d8410 100644 --- a/llm_infer_column_fields_test.go +++ b/internal/llm_infer_column_fields_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "testing" diff --git a/llm_prompts.go b/internal/llm_prompts.go similarity index 99% rename from llm_prompts.go rename to internal/llm_prompts.go index 5e15daa..8f3b65e 100644 --- a/llm_prompts.go +++ b/internal/llm_prompts.go @@ -1,4 +1,4 @@ -package main +package internal const ( DESC_PROMPT = `Generate a description for a column in a specific table in a data warehouse, diff --git a/llm_set_description.go b/internal/llm_set_description.go similarity index 98% rename from llm_set_description.go rename to internal/llm_set_description.go index 0f2e92f..d5ccad5 100644 --- a/llm_set_description.go +++ b/internal/llm_set_description.go @@ -1,4 +1,4 @@ -package main +package internal import ( "fmt" diff --git a/llm_set_tests.go b/internal/llm_set_tests.go similarity index 98% rename from llm_set_tests.go rename to internal/llm_set_tests.go index 3324a81..371865e 100644 --- a/llm_set_tests.go +++ b/internal/llm_set_tests.go @@ -1,4 +1,4 @@ -package main +package internal import ( "fmt" diff --git a/prep_build_dir.go b/internal/prep_build_dir.go similarity index 96% rename from prep_build_dir.go rename to internal/prep_build_dir.go index 172688b..be05fdd 100644 --- a/prep_build_dir.go +++ b/internal/prep_build_dir.go @@ -1,4 +1,4 @@ -package main +package internal import ( "errors" diff --git a/prep_build_dir_test.go b/internal/prep_build_dir_test.go similarity index 93% rename from prep_build_dir_test.go rename to internal/prep_build_dir_test.go index 8b87270..98ddbf5 100644 --- a/prep_build_dir_test.go +++ b/internal/prep_build_dir_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "os" diff --git a/set_connection_details.go b/internal/set_connection_details.go similarity index 99% rename from set_connection_details.go rename to internal/set_connection_details.go index b102a83..761d5bf 100644 --- a/set_connection_details.go +++ b/internal/set_connection_details.go @@ -1,4 +1,4 @@ -package main +package internal import ( "log" diff --git a/set_connection_details_test.go b/internal/set_connection_details_test.go similarity index 99% rename from set_connection_details_test.go rename to internal/set_connection_details_test.go index 6512220..bcdd8b6 100644 --- a/set_connection_details_test.go +++ b/internal/set_connection_details_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "os" diff --git a/staging_template.sql b/internal/staging_template.sql similarity index 100% rename from staging_template.sql rename to internal/staging_template.sql diff --git a/test_helpers.go b/internal/test_helpers.go similarity index 98% rename from test_helpers.go rename to internal/test_helpers.go index b96bd60..c42557d 100644 --- a/test_helpers.go +++ b/internal/test_helpers.go @@ -1,4 +1,4 @@ -package main +package internal import ( "os" diff --git a/internal/version.go b/internal/version.go new file mode 100644 index 0000000..79d4781 --- /dev/null +++ b/internal/version.go @@ -0,0 +1,3 @@ +package internal + +const VERSION = "0.0.25" diff --git a/write_files.go b/internal/write_files.go similarity index 96% rename from write_files.go rename to internal/write_files.go index a8374a7..c2c0f90 100644 --- a/write_files.go +++ b/internal/write_files.go @@ -1,4 +1,4 @@ -package main +package internal import ( "errors" diff --git a/write_files_test.go b/internal/write_files_test.go similarity index 97% rename from write_files_test.go rename to internal/write_files_test.go index 43a7ccf..2ea307d 100644 --- a/write_files_test.go +++ b/internal/write_files_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "strings" diff --git a/write_profile.go b/internal/write_profile.go similarity index 99% rename from write_profile.go rename to internal/write_profile.go index cfe5165..bbebade 100644 --- a/write_profile.go +++ b/internal/write_profile.go @@ -1,4 +1,4 @@ -package main +package internal import ( "log" diff --git a/write_profile_test.go b/internal/write_profile_test.go similarity index 98% rename from write_profile_test.go rename to internal/write_profile_test.go index 5c361d0..a2907e0 100644 --- a/write_profile_test.go +++ b/internal/write_profile_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "os" diff --git a/write_scaffold_project.go b/internal/write_scaffold_project.go similarity index 99% rename from write_scaffold_project.go rename to internal/write_scaffold_project.go index 94112cd..f15ae05 100644 --- a/write_scaffold_project.go +++ b/internal/write_scaffold_project.go @@ -1,4 +1,4 @@ -package main +package internal import ( "log" diff --git a/write_scaffold_project_test.go b/internal/write_scaffold_project_test.go similarity index 99% rename from write_scaffold_project_test.go rename to internal/write_scaffold_project_test.go index fc2f65d..116348c 100644 --- a/write_scaffold_project_test.go +++ b/internal/write_scaffold_project_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "os" diff --git a/write_staging_models.go b/internal/write_staging_models.go similarity index 98% rename from write_staging_models.go rename to internal/write_staging_models.go index fc1b428..9f9ff0f 100644 --- a/write_staging_models.go +++ b/internal/write_staging_models.go @@ -1,4 +1,4 @@ -package main +package internal import ( "embed" diff --git a/write_staging_models_test.go b/internal/write_staging_models_test.go similarity index 98% rename from write_staging_models_test.go rename to internal/write_staging_models_test.go index e896ac3..b6c6565 100644 --- a/write_staging_models_test.go +++ b/internal/write_staging_models_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "os" diff --git a/write_yaml.go b/internal/write_yaml.go similarity index 96% rename from write_yaml.go rename to internal/write_yaml.go index 93cf28c..11c2161 100644 --- a/write_yaml.go +++ b/internal/write_yaml.go @@ -1,4 +1,4 @@ -package main +package internal import ( "log" diff --git a/write_yaml_test.go b/internal/write_yaml_test.go similarity index 98% rename from write_yaml_test.go rename to internal/write_yaml_test.go index a72844d..7e33b21 100644 --- a/write_yaml_test.go +++ b/internal/write_yaml_test.go @@ -1,4 +1,4 @@ -package main +package internal import ( "os" diff --git a/main.go b/main.go index d9dd376..e8d85cc 100644 --- a/main.go +++ b/main.go @@ -1,102 +1,9 @@ package main import ( - "context" - "fmt" - "log" - "time" - - "github.com/fatih/color" - "github.com/gwenwindflower/tbd/sourcerer" + "github.com/gwenwindflower/tbd/cmd" ) -type Elapsed struct { - DbStart time.Time - ProcessingStart time.Time - DbElapsed float64 - ProcessingElapsed float64 -} - func main() { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - ps, err := FetchDbtProfiles() - if err != nil { - log.Fatalf("Error fetching dbt profiles: %v\n", err) - } - fr, err := Forms(ps) - if err != nil { - log.Fatalf("Error running form: %v\n", err) - } - if !fr.Confirm { - log.Fatal("ā›” User cancelled.") - } - cd := SetConnectionDetails(fr, ps) - - e := Elapsed{} - e.DbStart = time.Now() - - bd := fr.BuildDir - err = PrepBuildDir(bd) - if err != nil { - log.Fatalf("Error preparing build directory: %v\n", err) - } - dbc, err := sourcerer.GetConn(cd) - if err != nil { - log.Fatalf("Error getting database connection: %v\n", err) - } - err = dbc.ConnectToDb(ctx) - if err != nil { - log.Fatalf("Error connecting to database: %v\n", err) - } - fmt.Println("Connected to database") - ts, err := dbc.GetSourceTables(ctx) - if err != nil { - log.Fatalf("Error getting sources: %v\n", err) - } - fmt.Println("Got source tables") - fmt.Println("Putting columns on tables...") - err = sourcerer.PutColumnsOnTables(ctx, ts, dbc) - if err != nil { - log.Fatalf("Error putting columns on tables: %v\n", err) - } - - e.DbElapsed = time.Since(e.DbStart).Seconds() - // End of database interaction, start of processing - e.ProcessingStart = time.Now() - - if fr.GenerateDescriptions { - llm, err := GetLlm(fr) - if err != nil { - // Using Printf instead of log.Fatalf since the program doesn't - // need to totally fail if the API provider can't be fetched - fmt.Printf("Error getting API provider: %v\n", err) - } - fmt.Println("Generating descriptions and tests...") - InferColumnFields(llm, ts) - if err != nil { - // Using Printf instead of log.Fatalf since the program - // doesn't need to totally fail if there's an error in the column field inference - fmt.Printf("Error inferring column fields: %v\n", err) - } - } - fmt.Println("Writing files...") - if fr.CreateProfile { - WriteProfile(cd, bd) - } - if fr.ScaffoldProject { - s, err := WriteScaffoldProject(cd, bd, fr.ProjectName) - if err != nil { - log.Fatalf("Error scaffolding project: %v\n", err) - } - bd = s - } - err = WriteFiles(ts, bd, fr.Prefix) - if err != nil { - log.Fatalf("Error writing files: %v\n", err) - } - e.ProcessingElapsed = time.Since(e.ProcessingStart).Seconds() - pinkUnderline := color.New(color.FgMagenta).Add(color.Bold, color.Underline).SprintFunc() - fmt.Printf("\nšŸ Done in %.1fs fetching data and %.1fs writing files!\nYour YAML and SQL files are in the %s directory.", e.DbElapsed, e.ProcessingElapsed, pinkUnderline(fr.BuildDir)) + cmd.Execute() } diff --git a/version.go b/version.go deleted file mode 100644 index 2c920c1..0000000 --- a/version.go +++ /dev/null @@ -1,3 +0,0 @@ -package main - -const Version = "0.0.24"