chore: Cleaned up code.

This commit is contained in:
2026-06-15 09:26:48 -04:00
parent b47ca8f14d
commit a4417affa1
21 changed files with 445 additions and 294 deletions

View File

@@ -5,38 +5,40 @@ import "core:path/filepath"
import "core:strings"
cmd_remove :: proc(cmd: ^Command) {
if len(cmd.args) != 1 {
if len(cmd.args) != 1 {
print_command_help("remove")
return
}
return
}
path := cmd.args[0]
if len(strings.trim_space(path)) == 0 {
fmt.println("Error: No path provided")
return
}
path := cmd.args[0]
if len(strings.trim_space(path)) == 0 {
fmt.println("Error: No path provided")
return
}
abs_path: string
if filepath.is_abs(path) {
abs_path = path
} else {
resolved, abs_err := filepath.abs(path)
if abs_err != nil {
fmt.printf("Error getting absolute path: %v\n", abs_err)
return
}
abs_path = resolved
}
// TODO: Is this the best way to do it?
abs_path: string
if filepath.is_abs(path) {
abs_path = path
} else {
resolved, abs_err := filepath.abs(path)
if abs_err != nil {
fmt.printf("Error getting absolute path: %v\n", abs_err)
return
}
abs_path = resolved
}
db, db_ok := db_open(cmd.config_path)
if !db_ok {
return
}
defer db_close(&db)
db, db_ok := db_open(cmd.config_path)
if !db_ok {
return
}
defer db_close(&db)
if !db_delete(&db, abs_path) {
return
}
if !db_delete(&db, abs_path) {
return
}
fmt.printf("Removed %s from the database\n", abs_path)
fmt.printf("Removed %s from the database\n", abs_path)
}