Skip to content

Commit

Permalink
add clean subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
kobtea committed Dec 31, 2022
1 parent a751289 commit 43f5336
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions cmd/clean.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cmd

import (
"os"

"github.com/spf13/cobra"
)

// cleanCmd represents the clean command
var cleanCmd = &cobra.Command{
Use: "clean",
Short: "Remove contents at working directory",
RunE: func(cmd *cobra.Command, args []string) error {
if err := os.RemoveAll(cfg.WorkingDir); err != nil {
return err
}
if err := os.Mkdir(cfg.WorkingDir, 0755); err != nil {
return err
}
return nil
},
}

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

0 comments on commit 43f5336

Please sign in to comment.