feat: implemented initial login command
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user