Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions internal/cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func loginApiKey(r *config.Red_t, cmd *cobra.Command, name, server, apikey strin
print.Debug(r, "%d %s", status, string(res))

if err = api.StatusCode(status); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return false
}

Expand All @@ -37,7 +37,7 @@ func loginApiKey(r *config.Red_t, cmd *cobra.Command, name, server, apikey strin
r.AddServer(name, server, user.User.ApiKey, "", 0, user.User.ID)

if err = r.Save(); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return false
}

Expand Down Expand Up @@ -67,7 +67,7 @@ func loginPassword(r *config.Red_t, cmd *cobra.Command, name, server, username s
}

if password, err = r.Term.PromptPassword("Password", ""); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
continue
}

Expand All @@ -81,7 +81,7 @@ func loginPassword(r *config.Red_t, cmd *cobra.Command, name, server, username s

if err = api.StatusCode(status); err != nil {
print.Info("If Two-factor authentication is enabled, this login method will not work as it is not supported, please use Apikey instead, you will find the Apikey (Api access key) at /my/account\n")
print.Error(err.Error())
print.Error("%s", err.Error())
continue
}

Expand All @@ -96,7 +96,7 @@ func loginPassword(r *config.Red_t, cmd *cobra.Command, name, server, username s
r.AddServer(name, server, user.User.ApiKey, "", 0, user.User.ID)

if err = r.Save(); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return
}

Expand All @@ -110,7 +110,7 @@ func displayLogin(r *config.Red_t, cmd *cobra.Command) {
var apikey string
var err error

print.Info(text.FgGreen.Sprint("Welcome to Red an Redmine CLI\n") +
print.Info("%s", text.FgGreen.Sprint("Welcome to Red an Redmine CLI\n") +
"Before login make sure you have enabled `Enable REST web service`\nfind it in Administration -> Settings -> API or use url /settings?tab=api\nYou find ApiKey (API access key) from /my/account\n\n")

if alias, err = r.Term.PromptStringRequire("Redmine server alias (Used for multi redmine server support)", ""); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/cmd/issue/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func displayCreateIssue(r *config.Red_t, cmd *cobra.Command, path string) {
issue.Issue.ProjectID = projectID

if idNames, err = project.GetTrackers(r, projectID); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return
}

Expand Down Expand Up @@ -111,7 +111,7 @@ func displayCreateIssue(r *config.Red_t, cmd *cobra.Command, path string) {
}
case FIELD_PRIORITY:
if idNames, err = global.GetPriorities(r); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
}

id, _ := r.Term.Choose("Priority", idNames)
Expand All @@ -121,7 +121,7 @@ func displayCreateIssue(r *config.Red_t, cmd *cobra.Command, path string) {
}
case FIELD_TARGET_VERSION:
if idNames, err = project.GetVersions(r, projectID); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
}

id, _ := r.Term.Choose("Version", idNames)
Expand All @@ -136,7 +136,7 @@ func displayCreateIssue(r *config.Red_t, cmd *cobra.Command, path string) {
}
case FIELD_ASSIGN:
if idNames, err = project.GetAssigns(r, projectID); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
}

id, _ := r.Term.Choose("Assign", idNames)
Expand Down
16 changes: 8 additions & 8 deletions internal/cmd/issue/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func cmdIssueEditIssue(r *config.Red_t, cmd *cobra.Command, id, path string) {
print.Debug(r, "%d %s", status, string(body))

if err := api.StatusCode(status); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return
}

Expand Down Expand Up @@ -274,7 +274,7 @@ func cmdIssueEditIssue(r *config.Red_t, cmd *cobra.Command, id, path string) {
subject, err := r.Term.PromptString("Subject", viewIssue.Issue.Subject)

if err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
} else {
issue.Issue.Subject = subject
viewIssue.Issue.Subject = subject
Expand All @@ -283,7 +283,7 @@ func cmdIssueEditIssue(r *config.Red_t, cmd *cobra.Command, id, path string) {
idName, err := cmdIssueEditIssueStatus(r, viewIssue.Issue.AllowedStatuses)

if err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
} else {
issue.Issue.StatusID = idName.ID
viewIssue.Issue.Status = idName
Expand All @@ -292,7 +292,7 @@ func cmdIssueEditIssue(r *config.Red_t, cmd *cobra.Command, id, path string) {
idName, err := cmdIssueEditIssuePriority(r)

if err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
} else {
issue.Issue.PriorityID = idName.ID
viewIssue.Issue.Priority = idName
Expand All @@ -301,7 +301,7 @@ func cmdIssueEditIssue(r *config.Red_t, cmd *cobra.Command, id, path string) {
idName, err := cmdIssueEditIssueTracker(r, viewIssue.Issue.Project.ID)

if err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
} else {
issue.Issue.TrackerID = idName.ID
viewIssue.Issue.Tracker = idName
Expand All @@ -311,13 +311,13 @@ func cmdIssueEditIssue(r *config.Red_t, cmd *cobra.Command, id, path string) {
viewIssue.Issue.Description = issue.Issue.Description
case FIELD_NOTE:
if err = cmdIssueEditIssueNote(r, &issue); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
}
case FIELD_ASSIGN:
idName, err := cmdIssueEditIssueAssign(r, viewIssue.Issue.Project.ID)

if err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
} else {
issue.Issue.AssignedToID = idName.ID
viewIssue.Issue.AssignedTo = idName
Expand All @@ -326,7 +326,7 @@ func cmdIssueEditIssue(r *config.Red_t, cmd *cobra.Command, id, path string) {
idName, err := cmdIssueEditIssueTargetVersion(r, viewIssue.Issue.Project.ID)

if err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
} else {
issue.Issue.FixedVersionID = idName.ID
viewIssue.Issue.FixedVersion = idName
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/issue/note.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func cmdIssueNoteRun(r *config.Red_t, cmd *cobra.Command, args []string) {
print.Debug(r, "%d %s", status, string(res))

if err := api.StatusCode(status); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return
}

Expand Down
18 changes: 9 additions & 9 deletions internal/editor/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ func StartPage(exec, body string) {
}

if path, err = config.CreateTmpFile(body); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return
}

args = append(args, path)

if err = createFile(view, args, body); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return
}

if err = os.Remove(path); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
}
}

Expand All @@ -76,12 +76,12 @@ func createFile(editor string, arg []string, body string) error {
cmd.Stderr = os.Stderr

if err = cmd.Start(); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return err
}

if err = cmd.Wait(); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return err
}
return nil
Expand All @@ -93,22 +93,22 @@ func editor(editor, body string) string {
var err error

if path, err = config.CreateTmpFile(body); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return ""
}

if err = createFile(editor, []string{path}, body); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return ""
}

if data, err = os.ReadFile(path); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
return ""
}

if err = os.Remove(path); err != nil {
print.Error(err.Error())
print.Error("%s", err.Error())
}
return string(data)
}
4 changes: 2 additions & 2 deletions internal/print/print.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ func Debug(r *config.Red_t, format string, a ...any) {
return
}
if len(a) > 0 {
fmt.Println(text.FgHiBlack.Sprintf("DEBUG: "+format, a))
fmt.Println(text.FgHiBlack.Sprintf("DEBUG: "+format, a...))
return
}
fmt.Println(text.FgHiBlack.Sprintf("DEBUG: " + format))
fmt.Println(text.FgHiBlack.Sprint("DEBUG: " + format))
}

func PrintRowHead(r *config.Red_t, format string, a ...any) {
Expand Down
Loading