forked from donadonny/lora-pktgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lora-pktgen.go
69 lines (56 loc) · 1.48 KB
/
lora-pktgen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Copyright (c) 2016 Mainflux
*
* Mainflux server is licensed under an Apache license, version 2.0.
* All rights not explicitly granted in the Apache license, version 2.0 are reserved.
* See the included LICENSE file for more details.
*/
package main
import (
"fmt"
"log"
"github.com/mainflux/lora-pktgen/cmd"
"github.com/spf13/cobra"
)
func main() {
var s string
UDPHost := "0.0.0.0"
UDPPort := 1680
// print mainflux-cli banner
fmt.Println(banner)
////
// Status
////
var cmdStatus = &cobra.Command{
Use: "status",
Short: "Server status",
Long: `Mainflux server health checkt.`,
Run: func(cmdCobra *cobra.Command, args []string) {
s = cmd.Status()
},
}
var rootCmd = &cobra.Command{
Use: "maninflux-cli",
PersistentPreRun: func(cmdCobra *cobra.Command, args []string) {
// Set UDP server address
cmd.SetServerAddr(UDPHost, UDPPort)
},
}
// Root Commands
rootCmd.AddCommand(cmdStatus)
// Root Flags
rootCmd.PersistentFlags().StringVarP(
&UDPHost, "host", "m", UDPHost, "UDP Host address")
rootCmd.PersistentFlags().IntVarP(
&UDPPort, "port", "p", UDPPort, "UDP Host Port")
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
} else {
fmt.Println(s)
}
}
var banner = `
┬ ┌─┐┬─┐┌─┐ ┌─┐┬┌─┌┬┐┌─┐┌─┐┌┐┌
│ │ │├┬┘├─┤───├─┘├┴┐ │ │ ┬├┤ │││
┴─┘└─┘┴└─┴ ┴ ┴ ┴ ┴ ┴ └─┘└─┘┘└┘
`