summaryrefslogtreecommitdiff
path: root/doNewUser.go
blob: 880f15baaed2c03f854a0dccb9c63a005bef9202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

// An app to submit patches for the 30 GO GUI repos

import (
	"fmt"

	"go.wit.com/lib/fhelp"
	"go.wit.com/lib/gui/shell"
	"go.wit.com/lib/protobuf/forgepb"
	"go.wit.com/log"
)

func doNewUser() (string, error) {
	var s string
	var err error

	if shell.Exists(me.forge.Config.ReposPB) {
		// not a new user
		return s, err
	}

	if me.forge.Config.Mode == forgepb.ForgeMode_UNKNOWN {
		// this should never happen
		log.Info("You are a new user and we never introduced ourselves")
		if fhelp.QuestionUser("build goimports?") {
			log.Info("just a test")
		}
		if fhelp.QuestionUser("forge will not look for git repos in ~/go/src") {
			log.Info("ok, we will continue")
		}
	} else {
		log.Info("MODE NOT UNKNOWN")
	}

	// very likely new user
	pfile, _ := resources.ReadFile("resources/NEWUSER")
	log.Info("")
	log.Info(string(pfile))
	s = fmt.Sprintf("Initialize forge?")
	if fhelp.QuestionUser(s) {
	} else {
		me.sh.GoodExit("no? porque?")
	}
	if fhelp.QuestionUser("forge will not look for git repos in ~/go/src") {
	} else {
		me.sh.GoodExit("no? porque?")
	}

	me.forge.ScanRepoDir() // looks for new dirs, checks existing repos for changes
	if me.forge.Config.Mode == forgepb.ForgeMode_NEWUSER {
		log.Info("")
		log.Info(" A good thing to try as a new user is to rebuild forge.")
		log.Info(" This will attempt to download all the sources & needed tools.")
		log.Info("")
		log.Info(" Also, you can enable bash & zsh completion with --bash & --zsh")
		log.Info("")
		log.Info(" todo: make better notes here.")
		log.Info("")
		if fhelp.QuestionUser("test question") {
			log.Info("question true")
		} else {
			log.Info("question false")
		}
		me.forge.Config.Mode = forgepb.ForgeMode_MASTER
		err := me.forge.ConfigSave()
		if err != nil {
			log.Info("ConfigSave() failed", err)
		}
	}
	me.sh.GoodExit("try running: 'forge rebuild forge' to test out that forge is working on your machine")
	return s, err
}