summaryrefslogtreecommitdiff
path: root/doNewUser.go
blob: 7d504ceb6948a957b521caaf7fc7adf061d6794d (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
// 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 (
	"errors"
	"fmt"
	"path/filepath"

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

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

	if me.forge.IsModeUnknown() {
		// display banner. it's probably the first time forge was ever run on this machine
		dumpDebug()
		log.Info("----                                     ----")
		log.Info("----         Welcome to forge!!!         ----")
		log.Info("----                                     ----")
		me.forge.SetModeNewUser()
	}

	if !me.forge.IsModeNewUser() {
		panic("finally got out of NEWUSER")
		// you aren't a new user anymore
		return s, err
	}

	// very likely new user
	pfile, _ := resources.ReadFile("resources/NEWUSER")
	log.Info("")
	log.Info(string(pfile))

	gosrc := filepath.Join(ENV.Get("homedir"), "go/src")
	s = fmt.Sprintf("Scan %s for .git repos", gosrc)
	if fhelp.QuestionUser(s) {
		// me.forge.ScanRepoDir(gosrc) // looks for new dirs, checks existing repos for changes
	} else {
		// log.Info("question false")
		return "not scanned", errors.New("~/go/src not scanned")
	}

	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("")

	// turn off NEWUSER
	err = me.forge.SetMode(forgepb.ForgeMode_CLEAN)
	if err != nil {
		log.Info("ConfigSave() failed filename =", me.forge.Config.Filename, err)
		return "ConfigSave() failed", err
	} else {
		log.Info("ConfigSave() worked filename =", me.forge.Config.Filename)
	}
	return s, err
}