aboutsummaryrefslogtreecommitdiffstats
path: root/c_init.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-01-18 20:20:20 +0100
committerJoe <rbo@gmx.us>2024-01-18 20:20:20 +0100
commitbfc6e7a122d7cb9686823af6516a450f18222c28 (patch)
tree848aa48dc07d7a19f4a9602c5d2900916f853c00 /c_init.go
parentgo (diff)
downloadhardflip-bfc6e7a122d7cb9686823af6516a450f18222c28.tar.gz
hardflip-bfc6e7a122d7cb9686823af6516a450f18222c28.tar.bz2
hardflip-bfc6e7a122d7cb9686823af6516a450f18222c28.tar.xz
hardflip-bfc6e7a122d7cb9686823af6516a450f18222c28.tar.zst
hardflip-bfc6e7a122d7cb9686823af6516a450f18222c28.zip
nobody will every see this
Diffstat (limited to '')
-rw-r--r--c_init.go29
1 files changed, 25 insertions, 4 deletions
diff --git a/c_init.go b/c_init.go
index cd12001..d39ab71 100644
--- a/c_init.go
+++ b/c_init.go
@@ -52,6 +52,7 @@
package main
import (
+ "strconv"
"os"
"path/filepath"
)
@@ -63,11 +64,15 @@ type HardOpts struct {
Term string
}
+// HACK: fuck global vars
+var count int = 0
+
// this function recurses into the specified root directory in order to load
// every yaml file into memory
func c_recurse_data_dir(dir, root string, opts HardOpts,
ldirs *DirsList,
- name string, parent *DirsNode, depth uint16) {
+ name string, parent *DirsNode, depth uint16,
+ ui *HardUI) {
files, err := os.ReadDir(root + dir)
if err != nil {
c_die("could not read data directory", err)
@@ -84,7 +89,7 @@ func c_recurse_data_dir(dir, root string, opts HardOpts,
filename := file.Name()
if file.IsDir() == true {
c_recurse_data_dir(dir + filename + "/", root, opts, ldirs,
- file.Name(), &dir_node, depth + 1)
+ file.Name(), &dir_node, depth + 1, ui)
} else if filepath.Ext(filename) == ".yml" {
host_node := c_read_yaml_file(root + dir + filename)
if host_node == nil {
@@ -93,14 +98,30 @@ func c_recurse_data_dir(dir, root string, opts HardOpts,
host_node.Filename = filename
host_node.Parent = &dir_node
dir_node.lhost.add_back(host_node)
+ ui.s.Clear()
+ count += 1
+ text := "Loading " + strconv.Itoa(count) + " hosts"
+ text_len := len(text) / 2
+ i_draw_box(ui.s,
+ (ui.dim[W] / 2) - (text_len + 2),
+ (ui.dim[H] / 2) - 2,
+ (ui.dim[W] / 2) + (text_len + 2),
+ (ui.dim[H] / 2) + 2, " Loading hosts ", false)
+ i_draw_text(ui.s,
+ (ui.dim[W] / 2) - text_len,
+ (ui.dim[H] / 2),
+ (ui.dim[W] / 2) + text_len,
+ (ui.dim[H] / 2),
+ ui.def_style, text)
+ ui.s.Show()
}
}
}
-func c_load_data_dir(dir string, opts HardOpts) *DirsList {
+func c_load_data_dir(dir string, opts HardOpts, ui *HardUI) *DirsList {
ldirs := DirsList{}
- c_recurse_data_dir("", dir + "/", opts, &ldirs, "", nil, 1)
+ c_recurse_data_dir("", dir + "/", opts, &ldirs, "", nil, 1, ui)
return &ldirs
}