Files
gator/main.go
T

39 lines
667 B
Go
Raw Normal View History

2026-07-31 08:06:29 -05:00
package main
import (
"fmt"
"os"
"github.com/StevanFreeborn/gator/internal/command"
"github.com/StevanFreeborn/gator/internal/config"
"github.com/StevanFreeborn/gator/internal/state"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Not enough arguments provided. Usage: <command> <args>")
os.Exit(1)
}
c, err := config.Read()
if err != nil {
fmt.Printf("Error reading config file: %s", err)
}
cmd := os.Args[1]
args := os.Args[2:]
s := state.NewState(c, args)
registry := command.NewRegistry()
err = registry.RunCommand(cmd, s)
if err != nil {
fmt.Printf("Error running '%s' command: %s\n", cmd, err)
os.Exit(2)
}
os.Exit(0)
}