refactor: Got rid of go fallback code.

This commit is contained in:
2026-06-12 10:25:09 -04:00
parent dff5235d65
commit fcee4ca7b1
4 changed files with 2 additions and 61 deletions

View File

@@ -35,21 +35,6 @@ COMMANDS := []CommandInfo{
{"edit-config", "envr edit-config", "Edit your config with your default editor", ""},
}
IMPLEMENTED_COMMANDS := []string{
"init",
"version",
"deps",
"list",
"backup",
"add",
"remove",
"restore",
"edit-config",
"check",
"scan",
"sync",
}
parse_args :: proc() -> (cmd: Command, ok: bool) {
args := os.args
if len(args) < 2 {
@@ -103,15 +88,6 @@ parse_args :: proc() -> (cmd: Command, ok: bool) {
return cmd, true
}
is_implemented :: proc(name: string) -> bool {
for c in IMPLEMENTED_COMMANDS {
if c == name {
return true
}
}
return false
}
has_flag :: proc(cmd: ^Command, name: string) -> bool {
_, ok := cmd.flags[name]
if ok {

View File

@@ -113,7 +113,7 @@ new_config :: proc(private_key_paths: []string) -> Config {
exclude := make([dynamic]string, 0, 4)
append(&exclude, "*\\.envrc")
append(&exclude, "\\.local")
append(&exclude, "\\.local/")
append(&exclude, "node_modules")
append(&exclude, "vendor")
@@ -148,7 +148,7 @@ save_config :: proc(cfg: Config, force: bool = false) -> bool {
config_path, _ := filepath.join([]string{config_dir, "config.json"})
if !force && os.exists(config_path) {
if os.exists(config_path) && !force {
info, stat_err := os.stat(config_path, context.allocator)
if stat_err == nil {
defer os.file_info_delete(info, context.allocator)

View File

@@ -3,19 +3,12 @@ package main
import "core:fmt"
import "core:os"
GO_BINARY :: "./envr-go"
main :: proc() {
cmd, ok := parse_args()
if !ok {
return
}
if !is_implemented(cmd.name) {
fallback_to_go()
return
}
switch cmd.name {
case "init":
cmd_init(&cmd)
@@ -46,31 +39,4 @@ main :: proc() {
}
}
fallback_to_go :: proc() {
args := make([dynamic]string)
append(&args, "./envr-go")
for i in 1..<len(os.args) {
append(&args, os.args[i])
}
desc := os.Process_Desc{
command = args[:],
stdin = os.stdin,
stdout = os.stdout,
stderr = os.stderr,
}
p, err1 := os.process_start(desc)
if err1 != nil {
fmt.printf("Error: failed to run envr-go: %v\n", err1)
os.exit(1)
}
state, err2 := os.process_wait(p)
if err2 != nil {
fmt.printf("Error waiting for envr-go: %v\n", err2)
os.exit(1)
}
os.exit(int(state.exit_code))
}

View File

@@ -1 +0,0 @@
package main