From aae1495d5901079094846b2e43bc90dcdfcf4950 Mon Sep 17 00:00:00 2001 From: Spencer Brower Date: Wed, 1 Jul 2026 14:01:22 -0400 Subject: [PATCH] refactor: Declared commands with named fields instead of positional. --- cli.odin | 127 +++++++++++++++++++++++++++---------------------------- 1 file changed, 62 insertions(+), 65 deletions(-) diff --git a/cli.odin b/cli.odin index df92995..e3aed52 100644 --- a/cli.odin +++ b/cli.odin @@ -68,82 +68,79 @@ GLOBAL_FLAGS: bit_set[Flag_Type] = {.Help, .Config_File, .Color} COMMANDS := []CommandInfo { { - "init", - "envr init", - "Set up envr", - `The init command generates your initial config and saves it to + name = "init", + usage = "envr init", + short = "Set up envr", + long = `The init command generates your initial config and saves it to ~/.envr/config in JSON format.\n\nDuring setup, you will be prompted to select one or more ssh keys with which to encrypt your databse. **Make 100% sure** that you have **a remote copy** of this key somewhere, otherwise your data could be lost forever.`, - {}, - GLOBAL_FLAGS + {.Force}, - {}, - }, - {"scan", "envr scan", "Find and select .env files for backup", "", {}, GLOBAL_FLAGS, {}}, - { - "sync", - "envr sync", - "Update or restore your env backups", - "", - {}, - GLOBAL_FLAGS + {.Output}, - {}, + flags = GLOBAL_FLAGS + {.Force}, }, { - "backup", - "envr backup ", - "Import a .env file into envr", - "", - {"add"}, - GLOBAL_FLAGS, - {{name = "path", completion = "untracked-paths"}}, + name = "scan", + usage = "envr scan", + short = "Find and select .env files for backup", + flags = GLOBAL_FLAGS, }, { - "restore", - "envr restore ", - "Restore a .env file from the database", - "", - {}, - GLOBAL_FLAGS, - {{name = "path", completion = "tracked-paths"}}, - }, - {"list", "envr list", "View your tracked files", "", {}, GLOBAL_FLAGS + {.Output}, {}}, - { - "remove", - "envr remove ", - "Remove a .env file from your database", - "", - {}, - GLOBAL_FLAGS, - {{name = "path", completion = "tracked-paths"}}, + name = "sync", + usage = "envr sync", + short = "Update or restore your env backups", + flags = GLOBAL_FLAGS + {.Output}, }, { - "check", - "envr check [path]", - "Check if files are backed up", - "", - {}, - GLOBAL_FLAGS, - {{name = "path", optional = true}}, - }, - {"version", "envr version", "Show envr's version", "", {}, {.Help}, {}}, - { - "edit-config", - "envr edit-config", - "Edit your config with your default editor", - "", - {}, - GLOBAL_FLAGS, - {}, + name = "backup", + usage = "envr backup ", + short = "Import a .env file into envr", + aliases = {"add"}, + flags = GLOBAL_FLAGS, + args = {{name = "path", completion = "untracked-paths"}}, }, { - "nushell-completion", - "envr nushell-completion", - "Generate custom completions for nushell", - "", - {}, - {.Help}, - {}, + name = "restore", + usage = "envr restore ", + short = "Restore a .env file from the database", + flags = GLOBAL_FLAGS, + args = {{name = "path", completion = "tracked-paths"}}, + }, + { + name = "list", + usage = "envr list", + short = "View your tracked files", + flags = GLOBAL_FLAGS + {.Output}, + }, + { + name = "remove", + usage = "envr remove ", + short = "Remove a .env file from your database", + flags = GLOBAL_FLAGS, + args = {{name = "path", completion = "tracked-paths"}}, + }, + { + name = "check", + usage = "envr check [path]", + short = "Check if files are backed up", + flags = GLOBAL_FLAGS, + args = {{name = "path", optional = true}}, + }, + { + name = "version", + usage = "envr version", + short = "Show envr's version", + flags = {.Help}, + }, + { + name = "edit-config", + usage = "envr edit-config", + short = "Edit your config with your default editor", + flags = GLOBAL_FLAGS, + }, + { + name = "nushell-completion", + usage = "envr nushell-completion", + short = "Generate custom completions for nushell", + flags = {.Help}, }, }