|
1 | 1 | package main |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "fmt" |
4 | 5 | "os" |
5 | 6 |
|
6 | 7 | "github.com/Tom5521/ArchLinuxInstaller/data" |
7 | 8 | "github.com/Tom5521/ArchLinuxInstaller/src" |
8 | 9 | "github.com/Tom5521/MyGolangTools/commands" |
9 | | - "github.com/gookit/color" |
10 | 10 | ) |
11 | 11 |
|
12 | 12 | var sh = commands.Sh{} |
13 | 13 |
|
| 14 | +var HelpStr = ` |
| 15 | +Usage: |
| 16 | +#[bin] [argument] -[option] |
| 17 | +
|
| 18 | +Arguments: |
| 19 | +- help Print this text |
| 20 | +
|
| 21 | +- install Run all the nesesary functions to install completely Arch Linux |
| 22 | +
|
| 23 | +- pacstrap Only runs the pacstrap functions |
| 24 | +
|
| 25 | +- grub Only installs Grub |
| 26 | +
|
| 27 | +- newconfig Creates a new config overwriting the original |
| 28 | +
|
| 29 | +- part Open cfdisk to partitionate the install disk |
| 30 | +
|
| 31 | +- passwd Only changes the password of the new root |
| 32 | +
|
| 33 | +- mount Only mounts the disks in her routes |
| 34 | +
|
| 35 | +Options: |
| 36 | +Argument options will be applied before the config fil |
| 37 | +
|
| 38 | +-nopasswd Skip the passwd set |
| 39 | +
|
| 40 | +-nopacstrap Skip the pacstrap prosess |
| 41 | +
|
| 42 | +-nopart Skip the partitionating prosess (not open cfdisk) |
| 43 | +
|
| 44 | +-nogrub Don't install Grub |
| 45 | +
|
| 46 | +-noformat Don't format the partitions |
| 47 | +
|
| 48 | +-nomount Don't mount the partitions |
| 49 | +
|
| 50 | +-nopacmanconf Don't paste custom pacman config |
| 51 | +
|
| 52 | +-nowifi Don't configure for wifi |
| 53 | +
|
| 54 | +-nofstab Don't generate a fstab for the new system |
| 55 | +
|
| 56 | +-nokeymap Don't config the keymap for the new system |
| 57 | +
|
| 58 | +` |
| 59 | + |
| 60 | +func PrintHelp() { |
| 61 | + fmt.Print(HelpStr) |
| 62 | +} |
| 63 | + |
14 | 64 | func main() { |
15 | | - if len(os.Args) > 1 { |
16 | | - if os.Args[1] == "install" { |
17 | | - src.Wifi() |
18 | | - src.PacmanConf() |
19 | | - src.Format() |
20 | | - src.Mount() |
21 | | - src.Pacstrap() |
22 | | - src.Fstab() |
23 | | - src.Grub() |
24 | | - src.Keymap() |
25 | | - src.FinalCmds() |
26 | | - } |
27 | | - if os.Args[1] == "pacstrap" { |
28 | | - src.Wifi() |
29 | | - src.PacmanConf() |
30 | | - src.Mount() |
31 | | - src.Pacstrap() |
32 | | - } |
33 | | - if os.Args[1] == "grub" { |
34 | | - src.Mount() |
35 | | - src.Fstab() |
36 | | - src.Grub() |
37 | | - } |
38 | | - if os.Args[1] == "newconfig" { |
39 | | - data.NewYamlFile() |
40 | | - err := sh.Cmd("vim " + data.Pfilename) |
41 | | - if err != nil { |
42 | | - color.Red.Println("Error oppening vim." + err.Error()) |
43 | | - } |
| 65 | + if len(os.Args) == 0 { |
| 66 | + fmt.Println("Not enough arguments") |
| 67 | + return |
| 68 | + } |
| 69 | + switch os.Args[1] { |
| 70 | + case "help": |
| 71 | + PrintHelp() |
| 72 | + case "passwd": |
| 73 | + src.ConfigRootPasswd() |
| 74 | + case "part": |
| 75 | + src.Partitioning() |
| 76 | + case "install": |
| 77 | + src.Partitioning() |
| 78 | + src.Wifi() |
| 79 | + src.PacmanConf() |
| 80 | + src.Format() |
| 81 | + src.Mount() |
| 82 | + src.Pacstrap() |
| 83 | + src.Fstab() |
| 84 | + src.Grub() |
| 85 | + src.Keymap() |
| 86 | + src.ConfigRootPasswd() |
| 87 | + src.FinalCmds() |
| 88 | + case "pacstrap": |
| 89 | + src.Wifi() |
| 90 | + src.PacmanConf() |
| 91 | + src.Mount() |
| 92 | + src.Pacstrap() |
| 93 | + case "grub": |
| 94 | + src.Mount() |
| 95 | + src.Fstab() |
| 96 | + src.Grub() |
| 97 | + case "mount": |
| 98 | + src.Mount() |
| 99 | + case "newconfig": |
| 100 | + data.NewYamlFile() |
| 101 | + err := sh.Cmd("vim " + data.Pfilename) |
| 102 | + if err != nil { |
| 103 | + src.Error("Error oppening vim.\n" + err.Error()) |
44 | 104 | } |
45 | 105 | } |
46 | 106 | } |
0 commit comments