🍰 Personal Multi-Git Remote Manager
go git
0
fork

Configure Feed

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

feat(config): Add config-based defaults for verbosity and remotes

Fuwn 7ed8407a c02d2f40

+58 -2
+20
cmd/mugi/main.go
··· 41 41 return fmt.Errorf("config: %w", err) 42 42 } 43 43 44 + applyDefaults(&cmd, cfg) 45 + 44 46 tasks := ui.BuildTasks(cfg, cmd.Repo, cmd.Remotes) 45 47 if len(tasks) == 0 { 46 48 return fmt.Errorf("no matching repositories or remotes found") ··· 48 50 49 51 return ui.Run(cmd.Operation, tasks, cmd.Verbose, cmd.Force, cmd.Linear) 50 52 } 53 + 54 + func applyDefaults(cmd *cli.Command, cfg config.Config) { 55 + if cfg.Defaults.Verbose { 56 + cmd.Verbose = true 57 + } 58 + 59 + if cfg.Defaults.Linear { 60 + cmd.Linear = true 61 + } 62 + 63 + if len(cmd.Remotes) == 1 && cmd.Remotes[0] == "all" { 64 + opRemotes := cfg.Defaults.RemotesFor(cmd.Operation.String()) 65 + 66 + if len(opRemotes) > 0 { 67 + cmd.Remotes = opRemotes 68 + } 69 + } 70 + }
+8
config.example.yaml
··· 12 12 defaults: 13 13 remotes: [github, codeberg, sourcehut] 14 14 path_prefix: ~/Developer 15 + verbose: false 16 + linear: false 17 + pull: 18 + remotes: [github] 19 + push: 20 + remotes: [github, codeberg, sourcehut] 21 + fetch: 22 + remotes: [github, codeberg, sourcehut] 15 23 16 24 repos: 17 25 gemrest/windmark: {}
+30 -2
internal/config/config.go
··· 14 14 URL string `yaml:"url"` 15 15 } 16 16 17 + type OperationDefaults struct { 18 + Remotes []string `yaml:"remotes"` 19 + } 20 + 17 21 type Defaults struct { 18 - Remotes []string `yaml:"remotes"` 19 - PathPrefix string `yaml:"path_prefix"` 22 + Remotes []string `yaml:"remotes"` 23 + PathPrefix string `yaml:"path_prefix"` 24 + Verbose bool `yaml:"verbose"` 25 + Linear bool `yaml:"linear"` 26 + Pull OperationDefaults `yaml:"pull"` 27 + Push OperationDefaults `yaml:"push"` 28 + Fetch OperationDefaults `yaml:"fetch"` 20 29 } 21 30 22 31 type RepoRemotes map[string]string ··· 248 257 249 258 return path 250 259 } 260 + 261 + func (d Defaults) RemotesFor(operation string) []string { 262 + switch operation { 263 + case "pull": 264 + if len(d.Pull.Remotes) > 0 { 265 + return d.Pull.Remotes 266 + } 267 + case "push": 268 + if len(d.Push.Remotes) > 0 { 269 + return d.Push.Remotes 270 + } 271 + case "fetch": 272 + if len(d.Fetch.Remotes) > 0 { 273 + return d.Fetch.Remotes 274 + } 275 + } 276 + 277 + return d.Remotes 278 + }