refactor: Fixed cli command.

This commit is contained in:
2026-06-14 21:59:23 -04:00
parent 567cc8b1e2
commit 3db86f0d2e
2 changed files with 12 additions and 7 deletions

View File

@@ -46,23 +46,24 @@ COMMANDS := []CommandInfo {
},
{"version", "envr version", "Show envr's version", "", {}},
{"edit-config", "envr edit-config", "Edit your config with your default editor", "", {}},
{"nushell-completion", "envr nushell-completion", "Generate custom completions for nushell", "", {}},
{
"nushell-completion",
"envr nushell-completion",
"Generate custom completions for nushell",
"",
{},
},
}
parse_args :: proc() -> (cmd: Command, ok: bool) {
args := os.args
if len(args) < 2 {
if len(args) < 2 || args[1] == "--help" || args[1] == "-h" {
print_usage()
return Command{}, false
}
cmd.name = args[1]
if cmd.name == "--help" || cmd.name == "-h" {
print_usage()
return Command{}, false
}
cmd.args = make([dynamic]string)
cmd.flags = make(map[string]string)
cmd.bool_set = make(map[string]bool)

View File

@@ -17,18 +17,22 @@ cmd_backup :: proc(cmd: ^Command) {
file, ok := new_env_file(path)
if !ok {
// TODO: log a message
return
}
db, db_ok := db_open()
if !db_ok {
// TODO: log a message
return
}
defer db_close(&db)
if !db_insert(&db, file) {
// TODO: log a message
return
}
fmt.printf("Saved %s into the database\n", path)
}