mirror of
https://github.com/tailscale/tailscale.git
synced 2024-12-01 22:15:51 +00:00
cmd/tailscale/cli: use printf and outln consistently
Fix some fmt.Println and fmt.Printf calls that crept in since
5df7ac70d6
.
Signed-off-by: Mihai Parparita <mihai@tailscale.com>
This commit is contained in:
parent
02a765743e
commit
e846481731
@ -66,7 +66,7 @@ func runConfigureHost(ctx context.Context, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if isDSM6 {
|
if isDSM6 {
|
||||||
fmt.Printf("/dev/net/tun exists and has permissions 0666. Skipping setcap on DSM6.\n")
|
printf("/dev/net/tun exists and has permissions 0666. Skipping setcap on DSM6.\n")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,6 +80,6 @@ func runConfigureHost(ctx context.Context, args []string) error {
|
|||||||
if out, err := exec.Command("/bin/setcap", "cap_net_admin,cap_net_raw+eip", daemonBin).CombinedOutput(); err != nil {
|
if out, err := exec.Command("/bin/setcap", "cap_net_admin,cap_net_raw+eip", daemonBin).CombinedOutput(); err != nil {
|
||||||
return fmt.Errorf("setcap: %v, %s", err, out)
|
return fmt.Errorf("setcap: %v, %s", err, out)
|
||||||
}
|
}
|
||||||
fmt.Printf("Done. To restart Tailscale to use the new permissions, run:\n\n sudo synosystemctl restart pkgctl-Tailscale.service\n\n")
|
printf("Done. To restart Tailscale to use the new permissions, run:\n\n sudo synosystemctl restart pkgctl-Tailscale.service\n\n")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -308,18 +308,18 @@ func runStat(ctx context.Context, args []string) error {
|
|||||||
for _, a := range args {
|
for _, a := range args {
|
||||||
fi, err := os.Lstat(a)
|
fi, err := os.Lstat(a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("%s: %v\n", a, err)
|
printf("%s: %v\n", a, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fmt.Printf("%s: %v, %v\n", a, fi.Mode(), fi.Size())
|
printf("%s: %v, %v\n", a, fi.Mode(), fi.Size())
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
ents, _ := os.ReadDir(a)
|
ents, _ := os.ReadDir(a)
|
||||||
for i, ent := range ents {
|
for i, ent := range ents {
|
||||||
if i == 25 {
|
if i == 25 {
|
||||||
fmt.Printf(" ...\n")
|
printf(" ...\n")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
fmt.Printf(" - %s\n", ent.Name())
|
printf(" - %s\n", ent.Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -420,7 +420,7 @@ func runVia(ctx context.Context, args []string) error {
|
|||||||
v4 := tsaddr.UnmapVia(ipp.Addr())
|
v4 := tsaddr.UnmapVia(ipp.Addr())
|
||||||
a := ipp.Addr().As16()
|
a := ipp.Addr().As16()
|
||||||
siteID := binary.BigEndian.Uint32(a[8:12])
|
siteID := binary.BigEndian.Uint32(a[8:12])
|
||||||
fmt.Printf("site %v (0x%x), %v\n", siteID, siteID, netip.PrefixFrom(v4, ipp.Bits()-96))
|
printf("site %v (0x%x), %v\n", siteID, siteID, netip.PrefixFrom(v4, ipp.Bits()-96))
|
||||||
case 2:
|
case 2:
|
||||||
siteID, err := strconv.ParseUint(args[0], 0, 32)
|
siteID, err := strconv.ParseUint(args[0], 0, 32)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -437,7 +437,7 @@ func runVia(ctx context.Context, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(via)
|
outln(via)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/peterbourgon/ff/v3/ffcli"
|
"github.com/peterbourgon/ff/v3/ffcli"
|
||||||
)
|
)
|
||||||
@ -29,6 +28,6 @@ func runIDToken(ctx context.Context, args []string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(tr.IDToken)
|
outln(tr.IDToken)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,8 @@ func presentRiskToUser(riskType, riskMessage string) error {
|
|||||||
if riskAccepted(riskType) {
|
if riskAccepted(riskType) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
fmt.Println(riskMessage)
|
outln(riskMessage)
|
||||||
fmt.Printf("To skip this warning, use --accept-risk=%s\n", riskType)
|
printf("To skip this warning, use --accept-risk=%s\n", riskType)
|
||||||
|
|
||||||
interrupt := make(chan os.Signal, 1)
|
interrupt := make(chan os.Signal, 1)
|
||||||
signal.Notify(interrupt, syscall.SIGINT)
|
signal.Notify(interrupt, syscall.SIGINT)
|
||||||
@ -64,15 +64,15 @@ func presentRiskToUser(riskType, riskMessage string) error {
|
|||||||
for left := riskAbortTimeSeconds; left > 0; left-- {
|
for left := riskAbortTimeSeconds; left > 0; left-- {
|
||||||
msg := fmt.Sprintf("\rContinuing in %d seconds...", left)
|
msg := fmt.Sprintf("\rContinuing in %d seconds...", left)
|
||||||
msgLen = len(msg)
|
msgLen = len(msg)
|
||||||
fmt.Print(msg)
|
printf(msg)
|
||||||
select {
|
select {
|
||||||
case <-interrupt:
|
case <-interrupt:
|
||||||
fmt.Printf("\r%s\r", strings.Repeat(" ", msgLen+1))
|
printf("\r%s\r", strings.Repeat("x", msgLen+1))
|
||||||
return errAborted
|
return errAborted
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("\r%s\r", strings.Repeat(" ", msgLen))
|
printf("\r%s\r", strings.Repeat(" ", msgLen))
|
||||||
return errAborted
|
return errAborted
|
||||||
}
|
}
|
||||||
|
@ -571,9 +571,9 @@ func runUp(ctx context.Context, args []string) (retErr error) {
|
|||||||
|
|
||||||
data, err := json.MarshalIndent(js, "", "\t")
|
data, err := json.MarshalIndent(js, "", "\t")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("upOutputJSON marshalling error: %v", err)
|
printf("upOutputJSON marshalling error: %v", err)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(string(data))
|
outln(string(data))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(Stderr, "\nTo authenticate, visit:\n\n\t%s\n\n", *url)
|
fmt.Fprintf(Stderr, "\nTo authenticate, visit:\n\n\t%s\n\n", *url)
|
||||||
@ -711,7 +711,7 @@ func printUpDoneJSON(state ipn.State, errorString string) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("printUpDoneJSON marshalling error: %v", err)
|
log.Printf("printUpDoneJSON marshalling error: %v", err)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println(string(data))
|
outln(string(data))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user