refactor(odin): ported backup command.

This commit is contained in:
2026-06-11 21:04:39 -04:00
parent de2186a2e5
commit 1964698e35
5 changed files with 165 additions and 4 deletions

34
cmd_backup.odin Normal file
View File

@@ -0,0 +1,34 @@
package main
import "core:fmt"
import "core:strings"
cmd_backup :: proc(cmd: ^Command) {
if len(cmd.args) != 1 {
fmt.println("Usage: envr backup <path>")
return
}
path := cmd.args[0]
if len(strings.trim_space(path)) == 0 {
fmt.println("Error: No path provided")
return
}
file, ok := new_env_file(path)
if !ok {
return
}
db, db_ok := db_open()
if !db_ok {
return
}
defer db_close(&db)
if !db_insert(&db, file) {
return
}
fmt.printf("Saved %s into the database\n", path)
}