示例#1
0
文件: command.go 项目: kaz3439/ghrepo
func doCreate(c *cli.Context) {
	name := c.Args().First()
	if len(name) == 0 {
		return
	}

	// check configuration
	configuration, err := OpenConfiguration()
	if err != nil {
		fmt.Println(err)
		return
	}
	if configuration.GithubToken == "" {
		configuration.GithubToken = PromptPersonalGithubToken()
		configuration.Persist()
	}

	// set repository attributes
	newRepository := github.Repository{Name: &name}
	prompt := c.Bool(flagDetail)
	if description := GetRepositryField(flagDesc, c.String(flagDesc), prompt).(string); description != "" {
		newRepository.Description = &description
	}
	if homepage := GetRepositryField(flagHP, c.String(flagHP), prompt).(string); homepage != "" {
		newRepository.Homepage = &homepage
	}
	if teamid := GetRepositryField(flagTeamID, c.Int(flagTeamID), prompt).(int); teamid != 0 {
		newRepository.TeamID = &teamid
	}
	private := GetRepositryField(flagPrivate, c.Bool(flagPrivate), prompt).(bool)
	newRepository.Private = &private
	issue := GetRepositryField(flagIssue, c.Bool(flagIssue), prompt).(bool)
	newRepository.HasIssues = &issue
	wiki := GetRepositryField(flagWiki, c.Bool(flagWiki), prompt).(bool)
	newRepository.HasWiki = &wiki
	download := GetRepositryField(flagDownload, c.Bool(flagDownload), prompt).(bool)
	newRepository.HasDownloads = &download

	// create repository
	org := c.String(flagOrg)
	client := NewClient(configuration)
	repository, _ := observeChannel(client.CreateRepository(org, &newRepository))
	if repository == nil {
		return
	}

	output := "\n\n" +
		"=========================\n" +
		"                         \n" +
		"@{g}* We are sccessful in Creating a repository! Push an existing repository from the command line@{|}\n" +
		"                         \n" +
		"git remote add origin %s \n" +
		"git push -u origin master\n" +
		"                         \n" +
		"=========================\n" +
		"\n\n"
	color.Printf(output, *repository.GitURL)
}
示例#2
0
func RemoveUnnecessaryFeatures(repo *github.Repository) {
	repo.ArchiveURL = nil
	repo.AssigneesURL = nil
	repo.BlobsURL = nil
	repo.BranchesURL = nil
	repo.CloneURL = nil
	repo.CollaboratorsURL = nil
	repo.CommentsURL = nil
	repo.CommitsURL = nil
	repo.CompareURL = nil
	repo.ContentsURL = nil
	repo.ContributorsURL = nil
	repo.DownloadsURL = nil
	repo.EventsURL = nil
	repo.ForksURL = nil
	repo.GitCommitsURL = nil
	repo.GitRefsURL = nil
	repo.GitTagsURL = nil
	repo.GitURL = nil
	repo.HooksURL = nil
	repo.IssueCommentURL = nil
	repo.IssueEventsURL = nil
	repo.IssuesURL = nil
	repo.KeysURL = nil
	repo.LabelsURL = nil
	repo.LanguagesURL = nil
	repo.MergesURL = nil
	repo.MilestonesURL = nil
	repo.NotificationsURL = nil
	repo.Owner.EventsURL = nil
	repo.Owner.FollowersURL = nil
	repo.Owner.FollowingURL = nil
	repo.Owner.GistsURL = nil
	repo.Owner.OrganizationsURL = nil
	repo.Owner.ReceivedEventsURL = nil
	repo.Owner.ReposURL = nil
	repo.Owner.StarredURL = nil
	repo.Owner.SubscriptionsURL = nil
	repo.PullsURL = nil
	repo.ReleasesURL = nil
	repo.SSHURL = nil
	repo.SVNURL = nil
	repo.StargazersURL = nil
	repo.StatusesURL = nil
	repo.SubscribersURL = nil
	repo.SubscriptionURL = nil
	repo.TagsURL = nil
	repo.TeamsURL = nil
	repo.TreesURL = nil
}