More usage information

This commit is contained in:
Nox Sluijtman 2022-08-20 22:13:12 +02:00
parent 48b0972f30
commit 66f1e9efce

21
main.go
View file

@ -18,17 +18,22 @@ var (
char Character char Character
skillMap = make(map[string]int) skillMap = make(map[string]int)
statMap = make(map[string]int) statMap = make(map[string]int)
advantage, disadvantage bool advantage, disadvantage, stat_list, skill_list bool
) )
func parseFlags() { func parseFlags() {
flag.StringVar(&path, "file", "stats.json", "fock me") flag.StringVar(&path, "file", "stats.json", "Used to point to character sheet")
flag.StringVar(&path, "f", "stats.json", "fock me") flag.StringVar(&path, "f", "stats.json", "Used to point to character sheet")
flag.StringVar(&skillString, "skill", "", "Skill to parse") flag.StringVar(&skillString, "skill", "", "Skill to parse")
flag.StringVar(&statString, "stat", "", "Stat check") flag.StringVar(&statString, "stat", "", "Stat check")
flag.StringVar(&saveString, "save", "", "Saving throw to... throw") flag.StringVar(&saveString, "save", "", "Saving throw to... throw")
flag.BoolVar(&advantage, "advantage", advantage, "Roll with advantage") flag.BoolVar(&advantage, "advantage", advantage, "Roll with advantage")
flag.BoolVar(&disadvantage, "disadvantage", disadvantage, "Roll with disadvantage") flag.BoolVar(&disadvantage, "disadvantage", disadvantage, "Roll with disadvantage")
flag.BoolVar(&stat_list, "stat-list", false, "Print list of stats, can also be used with -save flag")
flag.BoolVar(&skill_list, "skill-list", false, "Print list of skills to be used in combination with the -skill flag")
flag.Parse() flag.Parse()
} }
@ -67,6 +72,14 @@ func main() {
initMaps() initMaps()
switch { switch {
case stat_list:
for i := 0; i < len(char.Stats); i++ {
fmt.Println(char.Stats[i].StatName)
}
case skill_list:
for i := 0; i < len(char.Skills); i++ {
fmt.Println(char.Skills[i].SkillName)
}
case advantage && disadvantage: case advantage && disadvantage:
fmt.Println("You can't roll with both advantage and disadvantage") fmt.Println("You can't roll with both advantage and disadvantage")
os.Exit(1) os.Exit(1)
@ -116,7 +129,7 @@ func main() {
} }
default: default:
fmt.Println("bollock") flag.Usage()
} }
} }