refactor: Update Taskfile.yml to use lowercase variable names for consistency
This commit is contained in:
+15
-17
@@ -1,15 +1,14 @@
|
||||
version: '3'
|
||||
|
||||
vars:
|
||||
APP_NAME: tele-proc
|
||||
GO_FILES:
|
||||
app_name: tele-proc
|
||||
go_files:
|
||||
sh: find . -name '*.go' -type f
|
||||
CONFIG_DIR: configs
|
||||
BUILD_DIR: build
|
||||
MAIN_RECEIVER: ./cmd/main/main.go
|
||||
HASURA_ENDPOINT: http://localhost:8080/v1/graphql
|
||||
SCHEMA_FILE: ./internal/repository/schema.graphql
|
||||
HASURA_SECRET: # Set your Hasura admin secret here
|
||||
config_dir: configs
|
||||
build_dir: build
|
||||
main_receiver: ./cmd/main/main.go
|
||||
hasura_endpoint: http://localhost:8080/v1/graphql
|
||||
schema_file: ./internal/repository/schema.graphql
|
||||
hasura_secret: # Set your Hasura admin secret here
|
||||
|
||||
tasks:
|
||||
all:
|
||||
@@ -26,7 +25,7 @@ tasks:
|
||||
desc: Build the receiver application
|
||||
cmds:
|
||||
- echo "Building receiver..."
|
||||
- go build -o {{.BUILD_DIR}}/receiver {{.MAIN_RECEIVER}}
|
||||
- go build -o {{.build_dir}}/receiver {{.main_receiver}}
|
||||
|
||||
run:
|
||||
desc: Run the receiver application with different configurations
|
||||
@@ -38,21 +37,21 @@ tasks:
|
||||
cmds:
|
||||
- task: build-receiver
|
||||
- echo "Running receiver in development mode..."
|
||||
- GO_ENV=dev {{.BUILD_DIR}}/receiver
|
||||
- GO_ENV=dev {{.build_dir}}/receiver listen
|
||||
|
||||
run-prod:
|
||||
desc: Run the receiver in production mode
|
||||
cmds:
|
||||
- task: build-receiver
|
||||
- echo "Running receiver in production mode..."
|
||||
- GO_ENV=prod {{.BUILD_DIR}}/receiver
|
||||
- GO_ENV=prod {{.build_dir}}/receiver
|
||||
|
||||
run-test:
|
||||
desc: Run the receiver in test mode
|
||||
cmds:
|
||||
- task: build-receiver
|
||||
- echo "Running receiver in test mode..."
|
||||
- GO_ENV=test {{.BUILD_DIR}}/receiver
|
||||
- GO_ENV=test {{.build_dir}}/receiver
|
||||
|
||||
upgrade:
|
||||
desc: Upgrade go dependencies
|
||||
@@ -62,7 +61,7 @@ tasks:
|
||||
- go mod tidy
|
||||
|
||||
install-test:
|
||||
desc: install ginkgo for testing
|
||||
desc: Install ginkgo for testing
|
||||
cmds:
|
||||
- echo "Installing ginkgo..."
|
||||
- go install github.com/onsi/ginkgo/v2/ginkgo
|
||||
@@ -78,7 +77,7 @@ tasks:
|
||||
desc: Clean build artifacts
|
||||
cmds:
|
||||
- echo "Cleaning build artifacts..."
|
||||
- rm -rf {{.BUILD_DIR}}
|
||||
- rm -rf {{.build_dir}}
|
||||
|
||||
fmt:
|
||||
desc: Format the code
|
||||
@@ -103,9 +102,8 @@ tasks:
|
||||
cmds:
|
||||
- echo "Downloading GraphQL schema..."
|
||||
- >
|
||||
gq {{.HASURA_ENDPOINT}} -H 'X-Hasura-Admin-Secret: {{.HASURA_SECRET}}' --introspect > {{.SCHEMA_FILE}}
|
||||
gq {{.hasura_endpoint}} -H 'X-Hasura-Admin-Secret: {{.hasura_secret}}' --introspect > {{.schema_file}}
|
||||
|
||||
|
||||
gen:
|
||||
desc: Generate code using genqlient
|
||||
cmds:
|
||||
|
||||
+32
-2
@@ -5,21 +5,50 @@ import (
|
||||
"caatsm/internal/handlers"
|
||||
"caatsm/internal/nats"
|
||||
"caatsm/pkg/utils"
|
||||
"os"
|
||||
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app := setupApp()
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
fmt.Printf("Error running application: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func setupApp() *cli.App {
|
||||
app := &cli.App{
|
||||
Name: "serial-read",
|
||||
Usage: "A serial port reading CLI application",
|
||||
Before: func(c *cli.Context) error {
|
||||
// parameter = config.GetParameter()
|
||||
return nil
|
||||
},
|
||||
Commands: []*cli.Command{
|
||||
{
|
||||
Name: "listen",
|
||||
Usage: "Listen to nats messages",
|
||||
Action: executeListen,
|
||||
},
|
||||
},
|
||||
}
|
||||
return app
|
||||
}
|
||||
|
||||
func executeListen(c *cli.Context) error {
|
||||
cfg, err := config.LoadConfig()
|
||||
log := utils.GetLogger()
|
||||
if err != nil {
|
||||
fmt.Printf("Error loading configuration: %v\n", err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
if err := config.ValidateConfig(cfg); err != nil {
|
||||
fmt.Printf("Invalid configuration: %v\n", err)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println("Loaded configuration successfully")
|
||||
@@ -28,4 +57,5 @@ func main() {
|
||||
handler := handlers.NewNatsHandler(cfg)
|
||||
|
||||
nats.Subscribe(cfg, &handlers.PlainTextMarshaler{}, handler)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -11,12 +11,14 @@ require (
|
||||
github.com/onsi/ginkgo/v2 v2.19.1
|
||||
github.com/onsi/gomega v1.34.1
|
||||
github.com/spf13/viper v1.19.0
|
||||
github.com/urfave/cli/v2 v2.27.3
|
||||
go.uber.org/zap v1.27.0
|
||||
golang.org/x/oauth2 v0.21.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
|
||||
github.com/fsnotify/fsnotify v1.7.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
|
||||
@@ -32,6 +34,7 @@ require (
|
||||
github.com/oklog/ulid v1.3.1 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/sagikazarmark/locafero v0.6.0 // indirect
|
||||
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
@@ -40,6 +43,7 @@ require (
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/vektah/gqlparser/v2 v2.5.16 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/crypto v0.25.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
|
||||
|
||||
Reference in New Issue
Block a user