diff --git a/main.go b/main.go index 486b272..66fa02b 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,20 @@ package main +import ( + "fmt" + "os" + + "github.com/bryanpedini/gitea-mirror-gitea/utils" +) + func main() { - githubOrg, githubToken, giteaHost, giteaToken := "", "", "", "" - migrateGithubToGitea(githubOrg, githubToken, giteaHost, giteaToken) + commandLineArgumentsSlice := os.Args[1:] + commandLineArguments := utils.StringSliceToMap(commandLineArgumentsSlice) + + if _, ok := commandLineArguments["--github"]; ok { + githubOrg, githubToken, giteaHost, giteaToken := "", "", "", "" + migrateGithubToGitea(githubOrg, githubToken, giteaHost, giteaToken) + } else { + fmt.Println("Usage: " + os.Args[0] + " [--github]") + } } diff --git a/utils/sliceToMap.go b/utils/sliceToMap.go new file mode 100644 index 0000000..f5ab7ab --- /dev/null +++ b/utils/sliceToMap.go @@ -0,0 +1,13 @@ +package utils + +// StringSliceToMap Converts a slice of strings into a map formed by +// keys equals to the slice values, and empty strings as map values. +func StringSliceToMap(slice []string) map[string]string { + ret := make(map[string]string) + + for i := 0; i < len(slice); i++ { + ret[slice[i]] = "" + } + + return ret +}