diff --git a/pkg/cmd/snapshot.go b/pkg/cmd/snapshot.go index ea4ea2c..0cadb76 100644 --- a/pkg/cmd/snapshot.go +++ b/pkg/cmd/snapshot.go @@ -17,7 +17,7 @@ package cmd import ( "os" - "github.com/desmo999r/formolcli/pkg/backup" + "github.com/desmo999r/formolcli/pkg/restic" "github.com/spf13/cobra" ) @@ -25,32 +25,22 @@ import ( var snapshotCmd = &cobra.Command{ Use: "snapshot", Short: "A brief description of your command", - Long: `A longer description that spans multiple lines and likely contains examples -and usage of using your command. For example: +} -Cobra is a CLI library for Go that empowers applications. -This application is a tool to generate the needed files -to quickly create a Cobra application.`, +var snapshotDeleteCmd = &cobra.Command{ + Use: "delete", + Short: "delete a snapshot", Run: func(cmd *cobra.Command, args []string) { - snapshot, _ := cmd.Flags().GetString("snapshot") - if err := backup.DeleteSnapshot(snapshot); err != nil { + snapshot, _ := cmd.Flags().GetString("snapshot-id") + if err := restic.DeleteSnapshot(snapshot); err != nil { os.Exit(1) } }, } func init() { - deleteCmd.AddCommand(snapshotCmd) - - // Here you will define your flags and configuration settings. - - // Cobra supports Persistent Flags which will work for this command - // and all subcommands, e.g.: - // snapshotCmd.PersistentFlags().String("foo", "", "A help for foo") - - // Cobra supports local flags which will only run when this command - // is called directly, e.g.: - // snapshotCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") - snapshotCmd.Flags().String("snapshot", "", "The snapshot to delete") - snapshotCmd.MarkFlagRequired("snapshot") + rootCmd.AddCommand(snapshotCmd) + snapshotCmd.AddCommand(snapshotDeleteCmd) + snapshotDeleteCmd.Flags().String("snapshot-id", "", "The snapshot to delete") + snapshotDeleteCmd.MarkFlagRequired("snapshot-id") }