summaryrefslogtreecommitdiff
path: root/structs.go
blob: be05974061db9626b15c414fe041f814d6d9ba25 (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
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
// Use of this source code is governed by the GPL 3.0

package main

import (
	"sync"

	"go.wit.com/dev/alexflint/arg"
	"go.wit.com/lib/debian"
	"go.wit.com/lib/env"
	"go.wit.com/lib/fhelp"
	"go.wit.com/lib/protobuf/argvpb"
	"go.wit.com/lib/protobuf/forgepb"
	"go.wit.com/lib/protobuf/zoopb"
)

var me *mainType

// this app's variables
type mainType struct {
	once sync.Once // one-time initialized data
	// "go.wit.com/dev/alexflint/arg"
	argv    *argvpb.Argv   // more experiments for bash handling
	pp      *arg.Parser    // for parsing the command line args.  Yay to alexf lint!
	myGui   *fhelp.GuiPrep // for initializing the GUI toolkits
	forge   *forgepb.Forge // your customized repo preferences and settings
	machine *zoopb.Machine // your customized repo preferences and settings
	homedir string         // where the user homedir is
}

func initForge() {
	if me.forge == nil {
		var err error
		me.forge, err = forgepb.Init()
		if err != nil {
			me.argv.BadExit("this tool requires forge", err)
		}
		me.forge.RescanRepos()
	}
	env.PrintTable()
	initMachine()
}

func initMachine() {
	if me.machine == nil {
		me.machine = debian.InitMachine()
	}
}