Skip to content

Commit

Permalink
add --version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed Apr 24, 2019
1 parent 1bf851e commit 7903781
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,22 @@ Link together Mavlink endpoints.
Flags:
--help Show context-sensitive help (also try
--help-long and --help-man).
--version print mavp2p version
-q, --quiet suppress info messages during
execution.
--print-errors print parse errors on screen.
execution
--print-errors print parse errors on screen
--hb-disable disable heartbeats
--hb-version=1 set mavlink version of heartbeats
--hb-systemid=125 set system id of heartbeats.it is
--hb-systemid=125 set system id of heartbeats. it is
recommended to set a different system
id for each router in the network.
id for each router in the network
--hb-period=5 set period of heartbeats
--apreqstream-disable do not request streams to Ardupilot
devices, that need an explicit request
in order to emit telemetry streams.
this task is usually delegated to the
router, to avoid conflicts in case
multiple ground stations are active.
multiple ground stations are active
--apreqstream-frequency=4 set the stream frequency to request
Args:
Expand Down
18 changes: 13 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ func main() {
kingpin.CommandLine.Help = "mavp2p " + Version + "\n\n" +
"Link together Mavlink endpoints."

quiet := kingpin.Flag("quiet", "suppress info messages during execution.").Short('q').Bool()
printErrors := kingpin.Flag("print-errors", "print parse errors on screen.").Bool()
version := kingpin.Flag("version", "print mavp2p version").Bool()

quiet := kingpin.Flag("quiet", "suppress info messages during execution").Short('q').Bool()
printErrors := kingpin.Flag("print-errors", "print parse errors on screen").Bool()

hbDisable := kingpin.Flag("hb-disable", "disable heartbeats").Bool()
hbVersion := kingpin.Flag("hb-version", "set mavlink version of heartbeats").Default("1").Enum("1", "2")
hbSystemId := kingpin.Flag("hb-systemid", "set system id of heartbeats."+
hbSystemId := kingpin.Flag("hb-systemid", "set system id of heartbeats"+
"it is recommended to set a different system id for each router in the network.").Default("125").Int()
hbPeriod := kingpin.Flag("hb-period", "set period of heartbeats").Default("5").Int()

Expand All @@ -109,14 +111,20 @@ func main() {
}
endpoints := kingpin.Arg("endpoints", desc).Strings()

kingpin.Parse()

// print version
if *version == true {
fmt.Println("mavp2p " + Version)
os.Exit(0)
}

// print usage if no args are provided
if len(os.Args) <= 1 {
kingpin.Usage()
os.Exit(1)
}

kingpin.Parse()

if len(*endpoints) < 2 {
initError("at least 2 endpoints are required")
}
Expand Down

0 comments on commit 7903781

Please sign in to comment.