6
0
mirror of https://github.com/grdl/git-get.git synced 2026-02-07 22:14:18 +00:00

Don't show usage on clone error

This commit is contained in:
Grzegorz Dlugoszewski
2020-05-29 10:50:52 +02:00
parent 3335c81aa4
commit b72f984512
2 changed files with 13 additions and 26 deletions

View File

@@ -11,9 +11,10 @@ import (
const ReposRoot = "/tmp/gitget"
var cmd = &cobra.Command{
Use: "git-get",
Use: "git-get <repo>",
Short: "git get",
RunE: Run,
Run: Run,
Args: cobra.ExactArgs(1),
Version: "0.0.0",
}
@@ -21,23 +22,22 @@ func init() {
//cmd.PersistentFlags().
}
func Run(cmd *cobra.Command, args []string) error {
func Run(cmd *cobra.Command, args []string) {
url, err := pkg.ParseURL(args[0])
if err != nil {
return err
}
exitIfError(err)
_, err = pkg.CloneRepo(url, ReposRoot, false)
return err
exitIfError(err)
}
func Execute() {
if err := cmd.Execute(); err != nil {
func main() {
err := cmd.Execute()
exitIfError(err)
}
func exitIfError(err error) {
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func main() {
Execute()
}