1
1
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

change(croc): shorten flag with builder

This commit is contained in:
Khang. Nguyen Khac Nguyen 2020-10-22 14:06:54 +07:00
parent 8e50b59671
commit 4070f12cbf

View file

@ -347,17 +347,14 @@ func (c *Client) Send(options TransferOptions) (err error) {
if err != nil {
return
}
var (
otherRelay string
otherPassphrase string
)
flags := &strings.Builder{}
if c.Options.RelayAddress != models.DEFAULT_RELAY {
otherRelay = "--relay " + c.Options.RelayAddress + " "
flags.WriteString("--relay " + c.Options.RelayAddress + " ")
}
if c.Options.RelayPassword != models.DEFAULT_PASSPHRASE {
otherPassphrase = "--pass " + c.Options.RelayPassword + " "
flags.WriteString("--pass " + c.Options.RelayPassword + " ")
}
fmt.Fprintf(os.Stderr, "Code is: %s\nOn the other computer run\n\ncroc %s%s%s\n", c.Options.SharedSecret, otherPassphrase, otherRelay, c.Options.SharedSecret)
fmt.Fprintf(os.Stderr, "Code is: %[1]s\nOn the other computer run\n\ncroc %[2]s%[1]s\n", c.Options.SharedSecret, flags.String())
if c.Options.Ask {
machid, _ := machineid.ID()
fmt.Fprintf(os.Stderr, "\rYour machine ID is '%s'\n", machid)