Skip to content

Commit

Permalink
change make logs quiet by default and adds a verbose flag to enable v…
Browse files Browse the repository at this point in the history
…erbose log output

Signed-off-by: olalekan odukoya <[email protected]>
  • Loading branch information
olamilekan000 committed Dec 24, 2024
1 parent 05ccb97 commit deb9406
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions cmd/limactl/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func newCopyCommand() *cobra.Command {
}

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

return copyCommand
}
Expand All @@ -43,23 +44,33 @@ func copyAction(cmd *cobra.Command, args []string) error {
return err
}

arg0, err := exec.LookPath("scp")
verbose, err := cmd.Flags().GetBool("verbose")
if err != nil {
return err
}
instances := make(map[string]*store.Instance)
scpFlags := []string{}
scpArgs := []string{}

debug, err := cmd.Flags().GetBool("debug")
if err == nil && debug {
verbose = true
}

arg0, err := exec.LookPath("scp")
if err != nil {
return err
}
if debug {
scpFlags = append(scpFlags, "-v")

instances := make(map[string]*store.Instance)
scpFlags := []string{}
scpArgs := []string{}

if !verbose {
scpFlags = append(scpFlags, "-q")
}

if recursive {
scpFlags = append(scpFlags, "-r")
}

legacySSH := sshutil.DetectOpenSSHVersion().LessThan(*semver.New("8.0.0"))
for _, arg := range args {
path := strings.Split(arg, ":")
Expand Down Expand Up @@ -119,7 +130,7 @@ func copyAction(cmd *cobra.Command, args []string) error {
sshCmd.Stdin = cmd.InOrStdin()
sshCmd.Stdout = cmd.OutOrStdout()
sshCmd.Stderr = cmd.ErrOrStderr()
logrus.Debugf("executing scp (may take a long time)): %+v", sshCmd.Args)
logrus.Debugf("executing scp (may take a long time): %+v", sshCmd.Args)

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

0 comments on commit deb9406

Please sign in to comment.