-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: 1998-felix <[email protected]>
- Loading branch information
1 parent
1a2256f
commit e073ad7
Showing
14 changed files
with
446 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
# Copyright (c) Abstract Machines | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
all: | ||
CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -o build/coap-cli-linux cmd/main.go | ||
CGO_ENABLED=0 GOOS=darwin go build -ldflags "-s -w" -o build/coap-cli-darwin cmd/main.go | ||
CGO_ENABLED=0 GOOS=windows go build -ldflags "-s -w" -o build/coap-cli-windows cmd/main.go | ||
INSTALL_DIR=/usr/local/bin | ||
BUILD_DIR=build | ||
BUILD_FLAGS=-ldflags "-s -w" | ||
|
||
.PHONY: all linux darwin windows install install-linux | ||
|
||
all: linux darwin windows | ||
|
||
linux: | ||
CGO_ENABLED=0 GOOS=linux go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-linux cmd/main.go | ||
|
||
darwin: | ||
CGO_ENABLED=0 GOOS=darwin go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-darwin cmd/main.go | ||
|
||
windows: | ||
CGO_ENABLED=0 GOOS=windows go build $(BUILD_FLAGS) -o $(BUILD_DIR)/coap-cli-windows cmd/main.go | ||
|
||
install: install-linux | ||
|
||
install-linux: | ||
@cp $(BUILD_DIR)/coap-cli-linux $(INSTALL_DIR)/coap-cli || { echo "Installation failed"; exit 1; } | ||
|
||
clean: | ||
rm -rf $(BUILD_DIR)/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package coapcli | ||
|
||
import ( | ||
"github.com/spf13/viper" | ||
) | ||
|
||
type config struct { | ||
Host string `mapstructure:"host"` | ||
Port string `mapstructure:"port"` | ||
ContentFormat int `mapstructure:"contentFormat"` | ||
Auth string `mapstructure:"auth"` | ||
Observe bool `mapstructure:"observe"` | ||
KeepAlive uint64 `mapstructure:"keep-alive"` | ||
MaxRetries uint32 `mapstructure:"max-retries"` | ||
Verbose bool `mapstructure:"verbose"` | ||
CertFile string `mapstructure:"cert-file"` | ||
KeyFile string `mapstructure:"key-file"` | ||
ClientCAFile string `mapstructure:"ca-file"` | ||
} | ||
|
||
func LoadConfig() (config, error) { | ||
viper.SetConfigName("config") | ||
viper.AddConfigPath(".") | ||
viper.SetConfigType("yaml") | ||
err := viper.ReadInConfig() | ||
if err != nil { | ||
return config{}, err | ||
} | ||
var cfg config | ||
err = viper.Unmarshal(&cfg) | ||
if err != nil { | ||
return config{}, err | ||
} | ||
return cfg, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
host: "localhost" | ||
port: "5683" | ||
auth: "" | ||
contentFormat: 50 | ||
keep-alive: 0 | ||
max-retries: 10 | ||
observe: false | ||
verbose: false | ||
cert-file: "" | ||
key-file: "" | ||
ca-file: "" |
Oops, something went wrong.