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:
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user