github.com/grantbow/fit@v0.7.1-0.20220916164603-1f7c88ac81e6/fitapp/Env.go (about) 1 package fitapp 2 3 import ( 4 "fmt" 5 bugs "github.com/grantbow/fit/issues" 6 "github.com/grantbow/fit/scm" 7 "strings" 8 ) 9 10 // Env is a subcommand to output detected editor, directory and scm type. 11 func Env(config bugs.Config) { 12 vcs, scmdir, scmerr := scm.DetectSCM(make(map[string]bool), config) 13 settingsOut := "" 14 if config.FitYml == "" { 15 settingsOut = "<missing>" 16 } else { 17 settingsOut = config.FitYml 18 } 19 fmt.Printf("Settings:\n\nEditor: %s\nRoot Directory: %s\nFit Directory: %s\nSettings file: %s\n\n", 20 getEditor(), config.FitDir, bugs.FitDirer(config), settingsOut) 21 22 if scmerr != nil { 23 fmt.Printf("VCS Type: <missing> (purge and commit commands unavailable)\n\n") 24 } else { 25 t := vcs.SCMTyper() 26 fmt.Printf("VCS Type: %s\n", t) 27 fmt.Printf("%s Directory: %s\n", t, scmdir) 28 // 29 fmt.Printf("Need Committing or Staging: ") 30 if b, err := vcs.SCMIssuesUpdaters(config); err == nil { 31 fmt.Printf("(nothing)\n\n") 32 } else { 33 fmt.Printf("%v\n\n", string(b)) // simplest implementation, doesn't clarify 34 } 35 } 36 fmt.Printf("Config:\n " + 37 strings.Replace( 38 strings.TrimLeft( 39 strings.Replace( 40 fmt.Sprintf("%#v\n", config), 41 ", ", "\n ", -1), // Replace 42 "bugs.Config"), // TrimLeft 43 ":", " : ", -1), // Replace 44 ) // Printf 45 fmt.Printf("\n") 46 }