Skip to content

Commit

Permalink
✨ Basic project creation added
Browse files Browse the repository at this point in the history
  • Loading branch information
patheticGeek committed Jan 20, 2022
1 parent 4e2d89f commit 365312d
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,38 @@ import (

func createProject(c *cli.Context) error {
url := c.String("url")
destination := c.String("destination")
preserveGit := c.Bool("preserve-git")

fmt.Println("Cloning repo: " + url)
fmt.Println("Cloning repo:", url)
fmt.Println("Destination:", destination)
fmt.Println("Preserve git:", preserveGit)
fmt.Println("")

_, err := git.PlainClone("./", false, &git.CloneOptions{
var depth int
if !preserveGit {
depth = 1
}

// Clone the repo
_, err := git.PlainClone(destination, false, &git.CloneOptions{
URL: url,
Progress: os.Stdout,
Depth: depth,
})

if !preserveGit {
// Delete the git folder
os.RemoveAll(destination + "/.git")
}

if err != nil {
fmt.Println("An error occurred cloning the repo")
return err
}

fmt.Println("")
fmt.Println("✨ Done")

return nil
}

Expand All @@ -44,6 +63,12 @@ func main() {
Required: true,
Usage: "The url of the repo to create project from",
},
&cli.StringFlag{
Name: "destination",
Aliases: []string{"d"},
Usage: "Path of the destination folder to clone to",
Value: "new-prjkt",
},
&cli.BoolFlag{
Name: "preserve-git",
Aliases: []string{"pg"},
Expand Down

0 comments on commit 365312d

Please sign in to comment.