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