Skip to content

Commit

Permalink
Merge pull request #2998 from olamilekan000/add-quiet-flag-to-command
Browse files Browse the repository at this point in the history
[limactl copy] change make logs quiet by default and adds a verbose flag to enable verbose log output
  • Loading branch information
AkihiroSuda authored Dec 25, 2024
2 parents 5fb9353 + 900d2a9 commit f0d3814
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion 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,6 +44,11 @@ func copyAction(cmd *cobra.Command, args []string) error {
return err
}

verbose, err := cmd.Flags().GetBool("verbose")
if err != nil {
return err
}

arg0, err := exec.LookPath("scp")
if err != nil {
return err
Expand All @@ -54,9 +60,17 @@ func copyAction(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}

if debug {
verbose = true
}

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

if recursive {
scpFlags = append(scpFlags, "-r")
}
Expand Down Expand Up @@ -119,7 +133,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 f0d3814

Please sign in to comment.