diff --git a/cmd/archive.go b/cmd/archive.go new file mode 100644 index 0000000..1b57fa6 --- /dev/null +++ b/cmd/archive.go @@ -0,0 +1,44 @@ +package cmd + +import ( + "fmt" + "github.com/iyear/tdl/app/archive" + "github.com/spf13/cobra" + "time" +) + +func NewBackup() *cobra.Command { + var dst string + + cmd := &cobra.Command{ + Use: "backup", + Short: "Backup your data", + RunE: func(cmd *cobra.Command, args []string) error { + if dst == "" { + dst = fmt.Sprintf("tdl-backup-%s.zip", time.Now().Format("2006-01-02-15_04_05")) + } + + return archive.Backup(cmd.Context(), dst) + }, + } + + cmd.Flags().StringVarP(&dst, "dst", "d", "", "destination file path. Default: tdl-backup-