mirror of
https://github.com/sbrow/envr.git
synced 2026-06-27 10:38:33 -04:00
fix: Fixed cli command.
This commit is contained in:
15
cli.odin
15
cli.odin
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user