refactor to use app package instead of service
refactor app to be composable
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package issuesCmd
|
||||
package issues
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package issuesCmd
|
||||
package issues
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -70,7 +70,6 @@ func runCommentCmd(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
func defaultCommentAuthor() string {
|
||||
if u, err := user.Current(); err == nil && u.Username != "" {
|
||||
return u.Username
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package issuesCmd
|
||||
package issues
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package issuesCmd
|
||||
package issues
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package issuesCmd
|
||||
package issues
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||
"github.com/LazyBachelor/LazyPM/internal/utils"
|
||||
"github.com/LazyBachelor/LazyPM/internal/utils/shellcomp"
|
||||
"github.com/charmbracelet/huh"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
@@ -112,7 +112,7 @@ func init() {
|
||||
CreateCmd.Flags().StringVarP(&createFlags.issueType, "type", "t", "task", "Issue type(bug, feature, task)")
|
||||
CreateCmd.Flags().IntVarP(&createFlags.priority, "priority", "p", 0, "Issue priority(0-4)")
|
||||
|
||||
CreateCmd.RegisterFlagCompletionFunc("type", utils.CompletionFunc(typeOptions))
|
||||
CreateCmd.RegisterFlagCompletionFunc("status", utils.CompletionFunc(statusOptions))
|
||||
CreateCmd.RegisterFlagCompletionFunc("priority", utils.CompletionFunc(priorityRange))
|
||||
CreateCmd.RegisterFlagCompletionFunc("type", shellcomp.CompletionFunc(typeOptions))
|
||||
CreateCmd.RegisterFlagCompletionFunc("status", shellcomp.CompletionFunc(statusOptions))
|
||||
CreateCmd.RegisterFlagCompletionFunc("priority", shellcomp.CompletionFunc(priorityRange))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package issuesCmd
|
||||
package issues
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package issuesCmd
|
||||
package issues
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||
"github.com/LazyBachelor/LazyPM/internal/utils"
|
||||
"github.com/LazyBachelor/LazyPM/internal/utils/shellcomp"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -79,7 +79,7 @@ func init() {
|
||||
|
||||
ListCmd.Flags().IntVarP(&listFlags.limit, "limit", "l", 25, "Limit the number of issues returned")
|
||||
|
||||
ListCmd.RegisterFlagCompletionFunc("status", utils.CompletionFunc(statusOptions))
|
||||
ListCmd.RegisterFlagCompletionFunc("type", utils.CompletionFunc(typeOptions))
|
||||
ListCmd.RegisterFlagCompletionFunc("priority", utils.CompletionFunc(priorityRange))
|
||||
ListCmd.RegisterFlagCompletionFunc("status", shellcomp.CompletionFunc(statusOptions))
|
||||
ListCmd.RegisterFlagCompletionFunc("type", shellcomp.CompletionFunc(typeOptions))
|
||||
ListCmd.RegisterFlagCompletionFunc("priority", shellcomp.CompletionFunc(priorityRange))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package issuesCmd
|
||||
package issues
|
||||
|
||||
import (
|
||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package issuesCmd
|
||||
package issues
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package issuesCmd
|
||||
package issues
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/LazyBachelor/LazyPM/internal/models"
|
||||
"github.com/LazyBachelor/LazyPM/internal/utils"
|
||||
"github.com/LazyBachelor/LazyPM/internal/utils/shellcomp"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
@@ -62,9 +62,9 @@ func init() {
|
||||
UpdateCmd.Flags().StringVarP(&updateFlags.issueType, "type", "t", "", "New issue type(bug, feature, task)")
|
||||
UpdateCmd.Flags().IntVarP(&updateFlags.priority, "priority", "p", 0, "New issue priority(0-5)")
|
||||
|
||||
UpdateCmd.RegisterFlagCompletionFunc("type", utils.CompletionFunc(typeOptions))
|
||||
UpdateCmd.RegisterFlagCompletionFunc("status", utils.CompletionFunc(statusOptions))
|
||||
UpdateCmd.RegisterFlagCompletionFunc("priority", utils.CompletionFunc(priorityRange))
|
||||
UpdateCmd.RegisterFlagCompletionFunc("type", shellcomp.CompletionFunc(typeOptions))
|
||||
UpdateCmd.RegisterFlagCompletionFunc("status", shellcomp.CompletionFunc(statusOptions))
|
||||
UpdateCmd.RegisterFlagCompletionFunc("priority", shellcomp.CompletionFunc(priorityRange))
|
||||
}
|
||||
|
||||
func getUpdateValues(cmd *cobra.Command) (map[string]interface{}, error) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package surveyCmd
|
||||
package survey
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package surveyCmd
|
||||
package survey
|
||||
|
||||
import (
|
||||
"github.com/LazyBachelor/LazyPM/pkg/task"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package surveyCmd
|
||||
package survey
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package surveyCmd
|
||||
package survey
|
||||
|
||||
import (
|
||||
"github.com/LazyBachelor/LazyPM/internal/utils"
|
||||
"github.com/LazyBachelor/LazyPM/internal/utils/shellcomp"
|
||||
"github.com/LazyBachelor/LazyPM/pkg/task"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
@@ -20,6 +20,6 @@ var StartCmd = &cobra.Command{
|
||||
func init() {
|
||||
StartCmd.Flags().StringVarP(&Task, "task", "t", "", "Specify task.")
|
||||
StartCmd.Flags().StringVarP(&InterfaceType, "interface", "i", "", "Specify interface.")
|
||||
StartCmd.RegisterFlagCompletionFunc("task", utils.CompletionFunc(task.ListTasks()))
|
||||
StartCmd.RegisterFlagCompletionFunc("interface", utils.CompletionFunc(task.ListInterfaces()))
|
||||
StartCmd.RegisterFlagCompletionFunc("task", shellcomp.CompletionFunc(task.ListTasks()))
|
||||
StartCmd.RegisterFlagCompletionFunc("interface", shellcomp.CompletionFunc(task.ListInterfaces()))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package surveyCmd
|
||||
package survey
|
||||
|
||||
import (
|
||||
"github.com/LazyBachelor/LazyPM/internal/commands/issues"
|
||||
@@ -14,7 +14,7 @@ var StatusCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func runStatusCmd(cmd *cobra.Command, args []string) error {
|
||||
app := issuesCmd.AppFromContext(cmd.Context())
|
||||
app := issues.AppFromContext(cmd.Context())
|
||||
if app == nil || app.CurrentFeedback == nil {
|
||||
cmd.Println("No validation status available.")
|
||||
return nil
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package surveyCmd
|
||||
package survey
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user