@@ -33,6 +33,7 @@ func newCopyCommand() *cobra.Command {
33
33
}
34
34
35
35
copyCommand .Flags ().BoolP ("recursive" , "r" , false , "copy directories recursively" )
36
+ copyCommand .Flags ().BoolP ("verbose" , "v" , false , "enable verbose output" )
36
37
37
38
return copyCommand
38
39
}
@@ -43,23 +44,33 @@ func copyAction(cmd *cobra.Command, args []string) error {
43
44
return err
44
45
}
45
46
46
- arg0 , err := exec . LookPath ( "scp " )
47
+ verbose , err := cmd . Flags (). GetBool ( "verbose " )
47
48
if err != nil {
48
49
return err
49
50
}
50
- instances := make (map [string ]* store.Instance )
51
- scpFlags := []string {}
52
- scpArgs := []string {}
51
+
53
52
debug , err := cmd .Flags ().GetBool ("debug" )
53
+ if err == nil && debug {
54
+ verbose = true
55
+ }
56
+
57
+ arg0 , err := exec .LookPath ("scp" )
54
58
if err != nil {
55
59
return err
56
60
}
57
- if debug {
58
- scpFlags = append (scpFlags , "-v" )
61
+
62
+ instances := make (map [string ]* store.Instance )
63
+ scpFlags := []string {}
64
+ scpArgs := []string {}
65
+
66
+ if ! verbose {
67
+ scpFlags = append (scpFlags , "-q" )
59
68
}
69
+
60
70
if recursive {
61
71
scpFlags = append (scpFlags , "-r" )
62
72
}
73
+
63
74
legacySSH := sshutil .DetectOpenSSHVersion ().LessThan (* semver .New ("8.0.0" ))
64
75
for _ , arg := range args {
65
76
path := strings .Split (arg , ":" )
@@ -117,9 +128,11 @@ func copyAction(cmd *cobra.Command, args []string) error {
117
128
118
129
sshCmd := exec .Command (arg0 , append (sshArgs , scpArgs ... )... )
119
130
sshCmd .Stdin = cmd .InOrStdin ()
120
- sshCmd .Stdout = cmd .OutOrStdout ()
121
- sshCmd .Stderr = cmd .ErrOrStderr ()
122
- logrus .Debugf ("executing scp (may take a long time)): %+v" , sshCmd .Args )
131
+ if verbose {
132
+ sshCmd .Stdout = cmd .OutOrStdout ()
133
+ sshCmd .Stderr = cmd .ErrOrStderr ()
134
+ logrus .Debugf ("executing scp (may take a long time): %+v" , sshCmd .Args )
135
+ }
123
136
124
137
// TODO: use syscall.Exec directly (results in losing tty?)
125
138
return sshCmd .Run ()
0 commit comments