(ctx context.Context, cfg *config.Config)
| 21 | ) |
| 22 | |
| 23 | func (c *client) MaybeStar(ctx context.Context, cfg *config.Config) { |
| 24 | if !cfg.State.Stargazer && cfg.State.RunCount%promptCycle == 0 { |
| 25 | starred, err := c.isStar(ctx) |
| 26 | if err != nil { |
| 27 | fmt.Println("enjoying git spr? [Y/n]") |
| 28 | fmt.Print(" please add a star at https://github.com/ejoffe/spr") |
| 29 | reader := bufio.NewReader(os.Stdin) |
| 30 | line, _ := reader.ReadString('\n') |
| 31 | line = strings.TrimSpace(line) |
| 32 | if line != "n" { |
| 33 | cfg.State.Stargazer = true |
| 34 | rake.LoadSources(cfg.State, |
| 35 | rake.YamlFileWriter(config_parser.InternalConfigFilePath())) |
| 36 | fmt.Println("Thank You! Happy Coding!") |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | if starred { |
| 41 | log.Debug().Bool("stargazer", true).Msg("MaybeStar") |
| 42 | cfg.State.Stargazer = true |
| 43 | rake.LoadSources(cfg.State, |
| 44 | rake.YamlFileWriter(config_parser.InternalConfigFilePath())) |
| 45 | } else { |
| 46 | log.Debug().Bool("stargazer", false).Msg("MaybeStar") |
| 47 | fmt.Print("enjoying git spr? add a GitHub star? [Y/n]:") |
| 48 | reader := bufio.NewReader(os.Stdin) |
| 49 | line, _ := reader.ReadString('\n') |
| 50 | line = strings.TrimSpace(line) |
| 51 | if line != "n" { |
| 52 | log.Debug().Msg("MaybeStar : adding star") |
| 53 | c.addStar(ctx) |
| 54 | cfg.State.Stargazer = true |
| 55 | rake.LoadSources(cfg.State, |
| 56 | rake.YamlFileWriter(config_parser.InternalConfigFilePath())) |
| 57 | fmt.Println("Thank You! Happy Coding!") |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func (c *client) isStar(ctx context.Context) (bool, error) { |
| 64 | iteration := 0 |
no test coverage detected