add a -block option

This commit is contained in:
idk
2020-01-09 18:32:17 -05:00
parent 2ea999f13f
commit 9831b13c00
3 changed files with 25 additions and 0 deletions

View File

@ -9,6 +9,7 @@ terminal i2pcontrol client.
-path default:"jsonrpc"
-password default:"itoopie"
-method default:"echo"
-block default:false
Installation with go get
@ -23,3 +24,9 @@ The methods that have been implemented are
graceful-shutdown : i2pcontrol:ShutdownGraceful
update : i2pcontrol:Update
find-update : i2pcontrol:FindUpdate
So, for instance, to initiate a graceful shutdown and block until the router is
shut down, use the command:
i2p-control -block -method=graceful-shutdown

Binary file not shown.

18
main.go
View File

@ -19,6 +19,7 @@ terminal i2pcontrol client.
-path default:"jsonrpc"
-password default:"itoopie"
-method default:"echo"
-block default:false
Installation with go get
@ -33,6 +34,12 @@ The methods that have been implemented are
graceful-shutdown : i2pcontrol:ShutdownGraceful
update : i2pcontrol:Update
find-update : i2pcontrol:FindUpdate
So, for instance, to initiate a graceful shutdown and block until the router is
shut down, use the command:
i2p-control -block -method=graceful-shutdown
`
var (
@ -43,6 +50,7 @@ var (
command = flag.String("method", "echo", "Method call to invoke")
shelp = flag.Bool("h", false, "Show the help message")
lhelp = flag.Bool("help", false, "Show the help message")
block = flag.Bool("block", false, "Block the terminal until the router is completely shut down")
)
func main() {
@ -112,4 +120,14 @@ func main() {
}
log.Println("You don't need an update")
}
for *block {
participatingTunnels, err := i2pcontrol.ParticipatingTunnels()
if err != nil {
log.Fatal(err)
}
if participatingTunnels < 1 {
*block = false
}
}
}