mirror of
https://github.com/sbrow/envr.git
synced 2026-08-26 18:03:32 -04:00
Compare commits
2 Commits
80353f387a
...
997f11b257
| Author | SHA1 | Date | |
|---|---|---|---|
| 997f11b257 | |||
| f5624e91f1 |
@@ -6,17 +6,14 @@
|
|||||||
|
|
||||||
3. procedures should be ordered by use, main at the top, then in the order they are called from main.
|
3. procedures should be ordered by use, main at the top, then in the order they are called from main.
|
||||||
|
|
||||||
4. Check for prealloc opportunities. i.e. `make([dynamic]string)` -> `make([dynamic]string, 5)`.
|
4. Test all command branches.
|
||||||
|
|
||||||
5. Test all command branches.
|
5. Generate md and man pages again.
|
||||||
|
|
||||||
6. Generate md and man pages again.
|
6. Bash Shell completion
|
||||||
|
|
||||||
7. Bash Shell completion
|
7. Add tests for untested commands.
|
||||||
|
|
||||||
8. Add tests for untested commands.
|
|
||||||
|
|
||||||
9. Audit ssh.odin for places where `#no_bounds_check` would be appropriate.
|
|
||||||
|
|
||||||
## Double-check AI output
|
## Double-check AI output
|
||||||
|
|
||||||
|
|||||||
@@ -68,76 +68,71 @@ GLOBAL_FLAGS: bit_set[Flag_Type] = {.Help, .Config_File, .Color}
|
|||||||
|
|
||||||
COMMANDS := []CommandInfo {
|
COMMANDS := []CommandInfo {
|
||||||
{
|
{
|
||||||
name = "init",
|
name = "init",
|
||||||
usage = "envr init",
|
usage = "envr init",
|
||||||
short = "Set up envr",
|
short = "Set up envr",
|
||||||
long = `The init command generates your initial config and saves it to
|
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
|
~/.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
|
encrypt your databse. **Make 100% sure** that you have **a remote copy** of this
|
||||||
key somewhere, otherwise your data could be lost forever.`,
|
key somewhere, otherwise your data could be lost forever.`,
|
||||||
flags = GLOBAL_FLAGS + {.Force},
|
flags = GLOBAL_FLAGS + {.Force},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "scan",
|
name = "scan",
|
||||||
usage = "envr scan",
|
usage = "envr scan",
|
||||||
short = "Find and select .env files for backup",
|
short = "Find and select .env files for backup",
|
||||||
flags = GLOBAL_FLAGS,
|
flags = GLOBAL_FLAGS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "sync",
|
name = "sync",
|
||||||
usage = "envr sync",
|
usage = "envr sync",
|
||||||
short = "Update or restore your env backups",
|
short = "Update or restore your env backups",
|
||||||
flags = GLOBAL_FLAGS + {.Output},
|
flags = GLOBAL_FLAGS + {.Output},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "backup",
|
name = "backup",
|
||||||
usage = "envr backup <path>",
|
usage = "envr backup <path>",
|
||||||
short = "Import a .env file into envr",
|
short = "Import a .env file into envr",
|
||||||
aliases = {"add"},
|
aliases = {"add"},
|
||||||
flags = GLOBAL_FLAGS,
|
flags = GLOBAL_FLAGS,
|
||||||
args = {{name = "path", completion = "untracked-paths"}},
|
args = {{name = "path", completion = "untracked-paths"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "restore",
|
name = "restore",
|
||||||
usage = "envr restore <path>",
|
usage = "envr restore <path>",
|
||||||
short = "Restore a .env file from the database",
|
short = "Restore a .env file from the database",
|
||||||
flags = GLOBAL_FLAGS,
|
flags = GLOBAL_FLAGS,
|
||||||
args = {{name = "path", completion = "tracked-paths"}},
|
args = {{name = "path", completion = "tracked-paths"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "list",
|
name = "list",
|
||||||
usage = "envr list",
|
usage = "envr list",
|
||||||
short = "View your tracked files",
|
short = "View your tracked files",
|
||||||
flags = GLOBAL_FLAGS + {.Output},
|
flags = GLOBAL_FLAGS + {.Output},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "remove",
|
name = "remove",
|
||||||
usage = "envr remove <path>",
|
usage = "envr remove <path>",
|
||||||
short = "Remove a .env file from your database",
|
short = "Remove a .env file from your database",
|
||||||
flags = GLOBAL_FLAGS,
|
flags = GLOBAL_FLAGS,
|
||||||
args = {{name = "path", completion = "tracked-paths"}},
|
args = {{name = "path", completion = "tracked-paths"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "check",
|
name = "check",
|
||||||
usage = "envr check [path]",
|
usage = "envr check [path]",
|
||||||
short = "Check if files are backed up",
|
short = "Check if files are backed up",
|
||||||
flags = GLOBAL_FLAGS,
|
flags = GLOBAL_FLAGS,
|
||||||
args = {{name = "path", optional = true}},
|
args = {{name = "path", optional = true}},
|
||||||
},
|
},
|
||||||
|
{name = "version", usage = "envr version", short = "Show envr's version", flags = {.Help}},
|
||||||
{
|
{
|
||||||
name = "version",
|
name = "edit-config",
|
||||||
usage = "envr version",
|
|
||||||
short = "Show envr's version",
|
|
||||||
flags = {.Help},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = "edit-config",
|
|
||||||
usage = "envr edit-config",
|
usage = "envr edit-config",
|
||||||
short = "Edit your config with your default editor",
|
short = "Edit your config with your default editor",
|
||||||
flags = GLOBAL_FLAGS,
|
flags = GLOBAL_FLAGS,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name = "nushell-completion",
|
name = "nushell-completion",
|
||||||
usage = "envr nushell-completion",
|
usage = "envr nushell-completion",
|
||||||
short = "Generate custom completions for nushell",
|
short = "Generate custom completions for nushell",
|
||||||
flags = {.Help},
|
flags = {.Help},
|
||||||
@@ -160,7 +155,7 @@ parse_args :: proc(args: []string, out: io.Stream, err: io.Stream) -> (cmd: Comm
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd.name = args[1]
|
cmd.name = args[1]
|
||||||
cmd.args = make([dynamic]string)
|
cmd.args = make([dynamic]string, 0, len(args[2:]))
|
||||||
|
|
||||||
overflow := parse_flags(&cmd.flags, args[2:])
|
overflow := parse_flags(&cmd.flags, args[2:])
|
||||||
for arg in overflow {
|
for arg in overflow {
|
||||||
|
|||||||
@@ -164,20 +164,26 @@ is_ed25519_key :: proc(
|
|||||||
return ok, nil
|
return ok, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
read_wire_string :: proc(data: ^[]u8) -> (s: []u8, ok: bool) {
|
read_wire_string :: proc(data: ^[]u8) -> (s: []u8, ok: bool) #no_bounds_check {
|
||||||
if len(data^) < 4 do return
|
if len(data^) < 4 {
|
||||||
|
return
|
||||||
|
}
|
||||||
length := endian.get_u32(data^[:4], .Big) or_return
|
length := endian.get_u32(data^[:4], .Big) or_return
|
||||||
data^ = data^[4:]
|
data^ = data^[4:]
|
||||||
|
|
||||||
if len(data^) < int(length) do return
|
if len(data^) < int(length) {
|
||||||
|
return
|
||||||
|
}
|
||||||
s = data^[:int(length)]
|
s = data^[:int(length)]
|
||||||
data^ = data^[int(length):]
|
data^ = data^[int(length):]
|
||||||
ok = true
|
ok = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
read_wire_u32 :: proc(data: ^[]u8) -> (v: u32, ok: bool) {
|
read_wire_u32 :: proc(data: ^[]u8) -> (v: u32, ok: bool) #no_bounds_check {
|
||||||
if len(data^) < 4 do return
|
if len(data^) < 4 {
|
||||||
|
return
|
||||||
|
}
|
||||||
v = endian.get_u32(data^[:4], .Big) or_return
|
v = endian.get_u32(data^[:4], .Big) or_return
|
||||||
data^ = data^[4:]
|
data^ = data^[4:]
|
||||||
ok = true
|
ok = true
|
||||||
|
|||||||
Reference in New Issue
Block a user