🍰 Personal Multi-Git Remote Manager
go git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: Add linear mode for sequential operations

Fuwn fe7f87b3 58efa862

+49 -14
+1 -1
cmd/mugi/main.go
··· 46 46 return fmt.Errorf("no matching repositories or remotes found") 47 47 } 48 48 49 - return ui.Run(cmd.Operation, tasks, cmd.Verbose, cmd.Force) 49 + return ui.Run(cmd.Operation, tasks, cmd.Verbose, cmd.Force, cmd.Linear) 50 50 }
+20
internal/cli/cli.go
··· 16 16 ConfigPath string 17 17 Verbose bool 18 18 Force bool 19 + Linear bool 19 20 Help bool 20 21 Version bool 21 22 } ··· 36 37 args, cmd.ConfigPath = extractConfigFlag(args) 37 38 args, cmd.Verbose = extractVerboseFlag(args) 38 39 args, cmd.Force = extractForceFlag(args) 40 + args, cmd.Linear = extractLinearFlag(args) 39 41 40 42 for _, arg := range args { 41 43 if arg == "-h" || arg == "--help" || arg == "help" { ··· 103 105 -c, --config <path> Override config file path 104 106 -V, --verbose Show detailed output 105 107 -f, --force Force push (use with caution) 108 + -l, --linear Run operations sequentially 106 109 107 110 Examples: 108 111 mugi pull Pull all repositories from all remotes ··· 194 197 195 198 return remaining, force 196 199 } 200 + 201 + func extractLinearFlag(args []string) ([]string, bool) { 202 + var remaining []string 203 + var linear bool 204 + 205 + for _, arg := range args { 206 + if arg == "-l" || arg == "--linear" { 207 + linear = true 208 + 209 + continue 210 + } 211 + 212 + remaining = append(remaining, arg) 213 + } 214 + 215 + return remaining, linear 216 + }
+28 -13
internal/ui/ui.go
··· 38 38 } 39 39 40 40 type Model struct { 41 - tasks []Task 42 - states map[string]taskState 43 - results map[string]git.Result 44 - spinner spinner.Model 45 - operation remote.Operation 46 - verbose bool 47 - force bool 48 - done bool 41 + tasks []Task 42 + states map[string]taskState 43 + results map[string]git.Result 44 + spinner spinner.Model 45 + operation remote.Operation 46 + verbose bool 47 + force bool 48 + linear bool 49 + currentTask int 50 + done bool 49 51 } 50 52 51 - func NewModel(op remote.Operation, tasks []Task, verbose, force bool) Model { 53 + func NewModel(op remote.Operation, tasks []Task, verbose, force, linear bool) Model { 52 54 s := spinner.New() 53 55 s.Spinner = spinner.Dot 54 56 s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("205")) ··· 67 69 operation: op, 68 70 verbose: verbose, 69 71 force: force, 72 + linear: linear, 70 73 } 71 74 } 72 75 ··· 77 80 func (m Model) Init() tea.Cmd { 78 81 cmds := []tea.Cmd{m.spinner.Tick} 79 82 80 - for _, task := range m.tasks { 81 - cmds = append(cmds, m.runTask(task)) 83 + if m.linear { 84 + if len(m.tasks) > 0 { 85 + cmds = append(cmds, m.runTask(m.tasks[0])) 86 + } 87 + } else { 88 + for _, task := range m.tasks { 89 + cmds = append(cmds, m.runTask(task)) 90 + } 82 91 } 83 92 84 93 return tea.Batch(cmds...) ··· 106 115 m.states[key] = taskSuccess 107 116 } 108 117 m.results[key] = msg.result 118 + m.currentTask++ 109 119 110 120 if m.allDone() { 111 121 m.done = true 122 + 112 123 return m, tea.Quit 124 + } 125 + 126 + if m.linear && m.currentTask < len(m.tasks) { 127 + return m, m.runTask(m.tasks[m.currentTask]) 113 128 } 114 129 } 115 130 ··· 228 243 return strings.Join(lines, "\n") 229 244 } 230 245 231 - func Run(op remote.Operation, tasks []Task, verbose, force bool) error { 246 + func Run(op remote.Operation, tasks []Task, verbose, force, linear bool) error { 232 247 if op == remote.Pull { 233 248 inits := NeedsInit(tasks) 234 249 if len(inits) > 0 { ··· 244 259 tasks = adjustPullTasks(tasks) 245 260 } 246 261 247 - model := NewModel(op, tasks, verbose, force) 262 + model := NewModel(op, tasks, verbose, force, linear) 248 263 p := tea.NewProgram(model) 249 264 250 265 _, err := p.Run()