github.com/supabase/cli@v1.168.1/cmd/stop.go (about)

     1  package cmd
     2  
     3  import (
     4  	"os"
     5  	"os/signal"
     6  
     7  	"github.com/spf13/afero"
     8  	"github.com/spf13/cobra"
     9  	"github.com/supabase/cli/internal/stop"
    10  )
    11  
    12  var (
    13  	noBackup  bool
    14  	projectId string
    15  
    16  	stopCmd = &cobra.Command{
    17  		GroupID: groupLocalDev,
    18  		Use:     "stop",
    19  		Short:   "Stop all local Supabase containers",
    20  		RunE: func(cmd *cobra.Command, args []string) error {
    21  			ctx, _ := signal.NotifyContext(cmd.Context(), os.Interrupt)
    22  			return stop.Run(ctx, !noBackup, projectId, afero.NewOsFs())
    23  		},
    24  	}
    25  )
    26  
    27  func init() {
    28  	flags := stopCmd.Flags()
    29  	flags.Bool("backup", true, "Backs up the current database before stopping.")
    30  	flags.StringVar(&projectId, "project-id", "", "Local project ID to stop.")
    31  	cobra.CheckErr(flags.MarkHidden("backup"))
    32  	flags.BoolVar(&noBackup, "no-backup", false, "Deletes all data volumes after stopping.")
    33  	rootCmd.AddCommand(stopCmd)
    34  }