mirror of
https://github.com/sbrow/envr.git
synced 2026-06-27 10:38:33 -04:00
refactor(odin): ported backup command.
This commit is contained in:
34
cmd_backup.odin
Normal file
34
cmd_backup.odin
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user