@@ -282,13 +282,33 @@ func handleConfigCommand() error {
282282}
283283
284284func printConfigUsage () error {
285- fmt .Println ("Config commands:" )
286- fmt .Println (" gith config show - Show current configuration" )
287- fmt .Println (" gith config reset - Reset configuration to defaults" )
288- fmt .Println (" gith config path - Show configuration file path" )
289- fmt .Println (" gith config update [--flavor=<flavor>] [--accent=<accent>] - Update configuration" )
290- fmt .Println (" <flavor> can be any of the catppuccin flavors (case insensitive)" )
291- fmt .Println (" <accent> can be any of the catppuccin accents (case insensitive)" )
285+ helpText := `
286+ Config commands:
287+ gith config show - Show current configuration
288+ gith config reset - Reset configuration to defaults
289+ gith config path - Show configuration file path
290+
291+ gith config update [--flavor=<flavor>] [--accent=<accent>] [--initFetch=<initFetch>]
292+ Update your configuration options. Flags are optional and can be combined.
293+
294+ --flavor=<flavor>
295+ Set the Catppuccin flavor (case insensitive). Available options:
296+ Latte, Frappe, Macchiato, Mocha
297+
298+ --accent=<accent>
299+ Set the Catppuccin accent color (case insensitive). Available options:
300+ Rosewater, Flamingo, Pink, Mauve, Red, Maroon, Peach, Yellow, Green,
301+ Teal, Blue, Sapphire, Sky, Lavender, Gray
302+
303+ --initFetch=<initFetch>
304+ Set fetch behavior on init. Available options:
305+ always - always fetch on init
306+ quick - fetch only for full load, skip for quick selects
307+ never - never fetch on init
308+ `
309+
310+ fmt .Println (helpText )
311+
292312 return nil
293313}
294314
@@ -299,8 +319,9 @@ func showConfig() error {
299319 }
300320
301321 fmt .Printf ("Current configuration:\n " )
302- fmt .Printf (" Flavor: %s\n " , cfg .Flavor )
303- fmt .Printf (" Accent: %s\n " , cfg .Accent )
322+ fmt .Printf (" Flavor: %s\n " , cfg .Flavor )
323+ fmt .Printf (" Accent: %s\n " , cfg .Accent )
324+ fmt .Printf (" Init Behaviour: %s\n " , cfg .InitBehaviour )
304325 return nil
305326}
306327
@@ -314,46 +335,35 @@ func updateConfig() error {
314335 return fmt .Errorf ("failed to load config: %w" , err )
315336 }
316337
317- // TODO: when adding more to configure, make sure to handle this automatically
318-
319- first := strings .ToLower (os .Args [3 ])
320- second := ""
321-
322- if len (os .Args ) >= 5 {
323- second = strings .ToLower (os .Args [4 ])
324- }
338+ args := os .Args [3 :]
339+ for _ , arg := range args {
340+ arg = strings .ToLower (arg )
325341
326- if flavor , found := strings .CutPrefix (first , "--flavor=" ); found {
327- if config .IsValidFlavor (flavor ) {
328- cfg .Flavor = flavor
329- } else {
330- return fmt .Errorf ("not a valid flavor: %s\n list of valid flavors: %s" , flavor , config .GetAvailableFlavors ())
331- }
332- } else if accent , found := strings .CutPrefix (first , "--accent=" ); found {
333- if config .IsValidAccent (accent ) {
334- cfg .Accent = accent
335- } else {
336- return fmt .Errorf ("not a valid accent: %s\n list of valid accent: %s" , accent , config .GetAvailableAccents ())
337- }
338- } else {
339- return fmt .Errorf ("'%s' is not a valid flag\n Run 'gith config help' to see valid flags" , strings .TrimPrefix (strings .Split (first , "=" )[0 ], "--" ))
340- }
342+ switch {
343+ case strings .HasPrefix (arg , "--flavor=" ):
344+ val := strings .TrimPrefix (arg , "--flavor=" )
345+ if ! config .IsValidFlavor (val ) {
346+ return fmt .Errorf ("not a valid flavor: %s\n valid flavors: %s" , val , strings .Join (config .GetAvailableFlavors (), ", " ))
347+ }
348+ cfg .Flavor = val
341349
342- if second != "" {
343- if flavor , found := strings .CutPrefix (second , "--flavor=" ); found {
344- if config .IsValidFlavor (flavor ) {
345- cfg .Flavor = flavor
346- } else {
347- return fmt .Errorf ("not a valid flavor: %s\n list of valid flavors: %s" , flavor , config .GetAvailableFlavors ())
350+ case strings .HasPrefix (arg , "--accent=" ):
351+ val := strings .TrimPrefix (arg , "--accent=" )
352+ if ! config .IsValidAccent (val ) {
353+ return fmt .Errorf ("not a valid accent: %s\n valid accents: %s" , val , strings .Join (config .GetAvailableAccents (), ", " ))
348354 }
349- } else if accent , found := strings .CutPrefix (second , "--accent=" ); found {
350- if config .IsValidAccent (accent ) {
351- cfg .Accent = accent
352- } else {
353- return fmt .Errorf ("not a valid accent: %s\n list of valid accent: %s" , accent , config .GetAvailableAccents ())
355+ cfg .Accent = val
356+
357+ case strings .HasPrefix (arg , "--initfetch=" ):
358+ val := strings .TrimPrefix (arg , "--initfetch=" )
359+ valid := map [string ]bool {"always" : true , "quick" : true , "never" : true }
360+ if ! valid [val ] {
361+ return fmt .Errorf ("not a valid initFetch: %s\n valid options: always, quick, never" , val )
354362 }
355- } else {
356- return fmt .Errorf ("'%s' is not a valid flag\n Run 'gith config help' to see valid flags" , strings .TrimPrefix (strings .Split (first , "=" )[0 ], "--" ))
363+ cfg .InitBehaviour = val
364+
365+ default :
366+ return fmt .Errorf ("'%s' is not a valid flag\n Run 'gith config help' to see valid flags" , strings .Split (arg , "=" )[0 ])
357367 }
358368 }
359369
0 commit comments