Skip to content

Commit 5cf98de

Browse files
committed
change make logs quiet by default and adds a verbose flag to enable verbose log output
Signed-off-by: olalekan odukoya <[email protected]>
1 parent 16f4051 commit 5cf98de

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

cmd/limactl/copy.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func newCopyCommand() *cobra.Command {
3333
}
3434

3535
copyCommand.Flags().BoolP("recursive", "r", false, "copy directories recursively")
36+
copyCommand.Flags().BoolP("verbose", "v", false, "enable verbose output")
3637

3738
return copyCommand
3839
}
@@ -43,23 +44,33 @@ func copyAction(cmd *cobra.Command, args []string) error {
4344
return err
4445
}
4546

46-
arg0, err := exec.LookPath("scp")
47+
verbose, err := cmd.Flags().GetBool("verbose")
4748
if err != nil {
4849
return err
4950
}
50-
instances := make(map[string]*store.Instance)
51-
scpFlags := []string{}
52-
scpArgs := []string{}
51+
5352
debug, err := cmd.Flags().GetBool("debug")
53+
if err == nil && debug {
54+
verbose = true
55+
}
56+
57+
arg0, err := exec.LookPath("scp")
5458
if err != nil {
5559
return err
5660
}
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")
5968
}
69+
6070
if recursive {
6171
scpFlags = append(scpFlags, "-r")
6272
}
73+
6374
legacySSH := sshutil.DetectOpenSSHVersion().LessThan(*semver.New("8.0.0"))
6475
for _, arg := range args {
6576
path := strings.Split(arg, ":")
@@ -117,9 +128,11 @@ func copyAction(cmd *cobra.Command, args []string) error {
117128

118129
sshCmd := exec.Command(arg0, append(sshArgs, scpArgs...)...)
119130
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+
}
123136

124137
// TODO: use syscall.Exec directly (results in losing tty?)
125138
return sshCmd.Run()

0 commit comments

Comments
 (0)