Working through authentication, role and policy basics

This commit is contained in:
2026-04-02 01:51:48 -04:00
parent ace452bce3
commit a70c88342b
7 changed files with 516 additions and 62 deletions

21
main.go
View File

@@ -16,17 +16,20 @@ type Command struct {
var commands = []Command{
{
Names: []string{"login", "l"},
Description: "Log into the system",
Handler: func(args []string) {
fmt.Println("Executing login with args:", args)
},
Names: []string{"role"},
Description: "Role Management",
Handler: roleMain,
},
{
Names: []string{"auth", "authenticate"},
Description: "Authenticate with a token",
Names: []string{"auth", "authorization"},
Description: "Role Management",
Handler: authenticateMain,
},
{
Names: []string{"policy"},
Description: "Policy Management",
Handler: policyMain,
},
}
func printMainUsage() {
@@ -43,7 +46,7 @@ func formatNames(names []string) string {
return strings.Join(names, ", ")
}
func findCommand(name string) *Command {
func findCommand(name string, commands []Command) *Command {
for _, cmd := range commands {
for _, n := range cmd.Names {
if n == name {
@@ -64,7 +67,7 @@ func main() {
subcommand := os.Args[1]
cmd := findCommand(subcommand)
cmd := findCommand(subcommand, commands)
if cmd == nil {
fmt.Println("Error: unknown command:", subcommand)
printMainUsage()