Refactor: apply new internal structurs #206
|
@ -42,12 +42,12 @@ var CmdIssuesList = cli.Command{
|
|||
|
||||
func runIssues(ctx *cli.Context) error {
|
||||
if ctx.Args().Len() == 1 {
|
||||
return runIssueDetail(ctx, ctx.Args().First())
|
||||
return runIssueDetail(ctx.Args().First())
|
||||
}
|
||||
return runIssuesList(ctx)
|
||||
}
|
||||
|
||||
func runIssueDetail(ctx *cli.Context, index string) error {
|
||||
func runIssueDetail(index string) error {
|
||||
login, owner, repo := intern.InitCommand(globalRepoValue, globalLoginValue, globalRemoteValue)
|
||||
|
||||
idx, err := argToIndex(index)
|
||||
|
|
|
@ -163,7 +163,6 @@ func runLabelCreate(ctx *cli.Context) error {
|
|||
|
||||
scanner := bufio.NewScanner(f)
|
||||
var i = 1
|
||||
// FIXME: if Gitea's API support create multiple labels once, we should move to that API.
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
color, name, description := splitLabelLine(line)
|
||||
|
|
|
@ -53,12 +53,12 @@ var CmdMilestonesList = cli.Command{
|
|||
|
||||
func runMilestones(ctx *cli.Context) error {
|
||||
if ctx.Args().Len() == 1 {
|
||||
return runMilestoneDetail(ctx, ctx.Args().First())
|
||||
return runMilestoneDetail(ctx.Args().First())
|
||||
}
|
||||
return runMilestonesList(ctx)
|
||||
}
|
||||
|
||||
func runMilestoneDetail(ctx *cli.Context, name string) error {
|
||||
func runMilestoneDetail(name string) error {
|
||||
login, owner, repo := intern.InitCommand(globalRepoValue, globalLoginValue, globalRemoteValue)
|
||||
client := login.Client()
|
||||
|
||||
|
@ -177,7 +177,7 @@ func runMilestonesCreate(ctx *cli.Context) error {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return runMilestoneDetail(ctx, mile.Title)
|
||||
return runMilestoneDetail(mile.Title)
|
||||
}
|
||||
|
||||
// CmdMilestonesClose represents a sub command of milestones to close an milestone
|
||||
|
|
|
@ -134,7 +134,7 @@ var CmdRepoCreate = cli.Command{
|
|||
|
||||
func runRepos(ctx *cli.Context) error {
|
||||
if ctx.Args().Len() == 1 {
|
||||
return runRepoDetail(ctx, ctx.Args().First())
|
||||
return runRepoDetail(ctx.Args().First())
|
||||
}
|
||||
return runReposList(ctx)
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ func runReposList(ctx *cli.Context) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func runRepoDetail(_ *cli.Context, path string) error {
|
||||
func runRepoDetail(path string) error {
|
||||
login := intern.InitCommandLoginOnly(globalLoginValue)
|
||||
client := login.Client()
|
||||
repoOwner, repoName := intern.GetOwnerAndRepo(path, login.User)
|
||||
|
@ -282,7 +282,7 @@ func runRepoCreate(ctx *cli.Context) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = runRepoDetail(ctx, repo.FullName); err != nil {
|
||||
if err = runRepoDetail(repo.FullName); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("%s\n", repo.HTMLURL)
|
||||
|
|
|
@ -44,8 +44,12 @@ func init() {
|
|||
yamlConfigPath = filepath.Join(dir, "tea.yml")
|
||||
}
|
||||
|
||||
func GetConfigPath() string {
|
||||
return yamlConfigPath
|
||||
}
|
||||
|
||||
func LoadConfig() error {
|
||||
ymlPath := yamlConfigPath
|
||||
ymlPath := GetConfigPath()
|
||||
exist, _ := utils.FileExist(ymlPath)
|
||||
if exist {
|
||||
fmt.Println("Found config file", ymlPath)
|
||||
|
@ -64,7 +68,7 @@ func LoadConfig() error {
|
|||
}
|
||||
|
||||
func SaveConfig() error {
|
||||
ymlPath := yamlConfigPath
|
||||
ymlPath := GetConfigPath()
|
||||
bs, err := yaml.Marshal(Config)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -137,10 +141,6 @@ func curGitRepoPath(repoValue, remoteValue string) (*Login, string, error) {
|
|||
return nil, "", errors.New("No Gitea login found. You might want to specify --repo (and --login) to work outside of a repository")
|
||||
}
|
||||
|
||||
func GetConfigPath() string {
|
||||
return yamlConfigPath
|
||||
}
|
||||
|
||||
func GetOwnerAndRepo(repoPath, user string) (string, string) {
|
||||
if len(repoPath) == 0 {
|
||||
return "", ""
|
||||
|
|
Loading…
Reference in New Issue
Block a user