direct-connect/go-dcpp

dcping: Set return code on error

modelrockettier opened this issue · 0 comments

The dcping ping command always exits with a 0 status, which makes it harder to integrate into scripts since you have to parse through the output to figure out if the hub is working.

It would be nice if dcping ping followed the standard conventions of returning 0 on success and non-zero if something goes wrong (it could also be handy to have different return codes for different errors, but even just a single error code would be nice to differentiate it from a successful ping).

E.g.

# dcping ping 127.0.0.1:1411 2>/dev/null
{"name":"GoHub","desc":"Hybrid hub","addr":["adcs://127.0.0.1:1411"],"encoding":"utf-8","soft":{"name":"GoHub","vers":"0.20.0","ext":["BAS0","TIGR","PING","UCMD","UCM0","ZLIF","BASE"]},"users":1}

# echo "Return code: $?"
Return code: 0

# dcping ping 127.0.0.1:411 2>/dev/null
{"addr":["127.0.0.1:411"],"status":"error"}

# echo "Return code: $?" # It would be nice if this was not 0
Return code: 0