Skip to content
This repository has been archived by the owner on Aug 12, 2021. It is now read-only.

Commit

Permalink
Add stop subcommand
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Dubois <jan.dubois@suse.com>
  • Loading branch information
jandubois committed Apr 23, 2021
1 parent 93b7df5 commit dbe7e1c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cmd/stop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

func init() {
rootCmd.AddCommand(stopCmd)
}

var stopCmd = &cobra.Command{
Use: "stop",
Short: "Stop a machine.",
Long: `Stop a machine.`,
RunE: stopCommand,
}

func stopCommand(cmd *cobra.Command, args []string) error {
api := newAPI()
defer api.Close()

host, err := api.Load(machineName)
if err != nil {
return err
}

fmt.Println("Powering down machine now...")
return host.Stop()
}

0 comments on commit dbe7e1c

Please sign in to comment.