This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.go
124 lines (102 loc) · 3.33 KB
/
types.go
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package main
const (
FILES_PATH string = "./files/"
INSTALLERS_PATH string = "./installers/"
)
type Config struct {
Name string // name of the Dotfile Project (required)
Description string // description of the Dotfile Project (optional) (default: "No Description Provided")
InstallPath string // path to the installation (required)
// if true, a git repo will be initialized and
// automatically updated with every action (optional) (default: false)
Git bool
Repository GitConfig
Dotfiles []Dotfile
Installers []Installer
}
type GitConfig struct {
RemoteName string // name of the git repository (required)
RemoteUrl string // name of the git repository (required)
Branch string // branch name of the git repository (optional) (default: "master")
}
type Dotfile struct {
Name string // the name of the dotfile (required)
Description string // the description of the dotfile (optional) (default: "No Description Provided")
Location string // the location of the dotfile (required)
Type string // the type of the dotfile (auto) (file, directory)
Priority int64 // the priority of the dotfile (optional) (default: 1) (1-3)
LastUpdate string // the last update date of the dotfile (auto)
}
type Installer struct {
Name string // the name of the installer (required)
Description string // the description of the installer (optional) (default: "No Description Provided")
Commands []Command // the command to execute the installer (required)
}
type Command struct {
Execute string // actual command (required)
Sudo bool // whether the command should be executed in sudo mode (optional) (default: false)
}
type Tmpl struct {
InstallPath string
Installer Installer
}
/* Template For The Installer Script */
// I hate go templates >:[
const installer_template = `
# -----------------------------------
# | |
# | Dotman Installer |
# | https://github.com/d3r1n/dotman |
# | |
# -----------------------------------
# Colored Output
# Reset
Color_Off='\033[0m' # Text Reset
# Regular Colors
Black='\033[0;30m' # Black
Red='\033[0;31m' # Red
Green='\033[0;32m' # Green
Yellow='\033[0;33m' # Yellow
Blue='\033[0;34m' # Blue
Purple='\033[0;35m' # Purple
Cyan='\033[0;36m' # Cyan
White='\033[0;37m' # White
# Bold
BBlack='\033[1;30m' # Black
BRed='\033[1;31m' # Red
BGreen='\033[1;32m' # Green
BYellow='\033[1;33m' # Yellow
BBlue='\033[1;34m' # Blue
BPurple='\033[1;35m' # Purple
BCyan='\033[1;36m' # Cyan
BWhite='\033[1;37m' # White
# Installation Location
install_path={{ .InstallPath }}
# Setup Function
function setup_point() {
printf "${BWhite}"
printf "\n --- Dotman Installer --- \n"
printf "https://github.com/d3r1n/dotman\n"
printf "${Color_Off}"
printf "\n"
printf "Copying Files from ${BBlue}./files/${Color_Off} to ${BBlue}${install_path}${Color_Off}\n"
cp -r ./files/* $install_path
printf "${BWhite}"
printf "\n --- User Defined Commands --- \n"
printf "${Color_Off}"
printf "\n"
}
# User defined commands
function run_point() {
{{ range .Installer.Commands }}
{{ if .Sudo }}
sudo {{ .Execute}}
{{ else }}
{{ .Execute }}
{{ end }}
{{ end }}
}
# Entry points
setup_point
run_point
`