From 34434acb6cd72e4c49f6b36898876258aa114be4 Mon Sep 17 00:00:00 2001 From: Fellipe Leonardo <112525075+neoRandom@users.noreply.github.com> Date: Mon, 17 Aug 2026 16:08:51 -0300 Subject: [PATCH 1/4] docs: update guide about CLI management --- README.md | 30 +++++++++++++++++++++++++- internal/infrastructure/driver/cli.go | 31 ++++++++++++--------------- 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 90d8546..c0efef5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,35 @@ Go + SQLite Echo + SQLC + Goose ``` -## API +## CLI Management + +```text +Usage: + keepitup [args...] + +Nouns: + game add + update + delete + access grant + revoke + player add + rename + passwd + passwd-force + delete + auth validate-passwd + hash-passwd + check-passwd + data games + shared + interactions + session save + resume + pause +``` + +## HTTP API ```text POST /login username + password → set cookies diff --git a/internal/infrastructure/driver/cli.go b/internal/infrastructure/driver/cli.go index b0b88cc..cee4820 100644 --- a/internal/infrastructure/driver/cli.go +++ b/internal/infrastructure/driver/cli.go @@ -22,10 +22,10 @@ var ( ErrWrongArgCount = errors.New("wrong number of arguments") ) -const usage = `keep-it-up — system management CLI +const usage = `keepitup — system management CLI Usage: - keep-it-up [args...] + keepitup [args...] Nouns: game add @@ -38,18 +38,15 @@ Nouns: passwd passwd-force delete - auth validate-password - hash-password - check-password + auth validate-passwd + hash-passwd + check-passwd data games shared interactions session save resume pause - -Note: player login is not exposed here; it belongs to an interactive/session -driver, not an administrative one. ` // Deps groups the driver ports and I/O streams the CLI needs. It is a @@ -320,34 +317,34 @@ func (c *CLI) runAuth(ctx context.Context, args []string) error { } verb, rest := args[0], args[1:] switch verb { - case "validate-password": + case "validate-passwd": if len(rest) != 1 { - return wrongArgs("auth validate-password", "auth validate-password ") + return wrongArgs("auth validate-passwd", "auth validate-passwd ") } if err := c.d.Auth.IsPasswordValid(rest[0]); err != nil { - return fmt.Errorf("auth validate-password: %w", err) + return fmt.Errorf("auth validate-passwd: %w", err) } fmt.Fprintln(c.d.Stdout, "valid") return nil - case "hash-password": + case "hash-passwd": if len(rest) != 1 { - return wrongArgs("auth hash-password", "auth hash-password ") + return wrongArgs("auth hash-passwd", "auth hash-passwd ") } hash, err := c.d.Auth.GeneratePasswordHash(rest[0]) if err != nil { - return fmt.Errorf("auth hash-password: %w", err) + return fmt.Errorf("auth hash-passwd: %w", err) } fmt.Fprintln(c.d.Stdout, hash) return nil - case "check-password": + case "check-passwd": if len(rest) != 2 { - return wrongArgs("auth check-password", "auth check-password ") + return wrongArgs("auth check-passwd", "auth check-passwd ") } ok, err := c.d.Auth.CheckPlayerPassword(ctx, rest[0], rest[1]) if err != nil { - return fmt.Errorf("auth check-password: %w", err) + return fmt.Errorf("auth check-passwd: %w", err) } fmt.Fprintln(c.d.Stdout, ok) return nil From 6920289f13f716ee7a517df3e86592797cc86adb Mon Sep 17 00:00:00 2001 From: Fellipe Leonardo <112525075+neoRandom@users.noreply.github.com> Date: Mon, 17 Aug 2026 18:15:22 -0300 Subject: [PATCH 2/4] refactor!: enhance core driver interfaces - defined Authentication.LoginPlayer signature. it will return a AuthResult struct - the AuthResult model contains the logged player and a JWT token - fixed ListPlayerGames requiring gameId (???) IMPORTANT: further refactor is needed to comply with new ListPlayerGames signature --- internal/application/usecase/authentication.go | 8 ++++++-- internal/application/usecase/data_fetching.go | 2 +- internal/core/interface/driver/driver.go | 4 ++-- internal/core/model/model.go | 10 +++++++++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/internal/application/usecase/authentication.go b/internal/application/usecase/authentication.go index 784065c..a7c731b 100644 --- a/internal/application/usecase/authentication.go +++ b/internal/application/usecase/authentication.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "keep-it-up/internal/core/model" "keep-it-up/internal/infrastructure/database" "strings" @@ -71,6 +72,9 @@ func (uc *Authentication) CheckPlayerPassword(ctx context.Context, username stri return true, nil } -func (uc *Authentication) LoginPlayer(ctx context.Context, username string, password string) { - +func (uc *Authentication) LoginPlayer( + ctx context.Context, username string, password string, +) (model.AuthResult, error) { + // TODO: Implement + return model.AuthResult{}, nil } diff --git a/internal/application/usecase/data_fetching.go b/internal/application/usecase/data_fetching.go index 64546ca..e4ee3dc 100644 --- a/internal/application/usecase/data_fetching.go +++ b/internal/application/usecase/data_fetching.go @@ -13,7 +13,7 @@ func NewDataFetching() *DataFetching { } func (uc *DataFetching) ListPlayerGames( - ctx context.Context, gameId int64, playerId int64, + ctx context.Context, playerId int64, ) ([]database.Game, error) { return nil, nil } diff --git a/internal/core/interface/driver/driver.go b/internal/core/interface/driver/driver.go index ca2f579..87e5fc7 100644 --- a/internal/core/interface/driver/driver.go +++ b/internal/core/interface/driver/driver.go @@ -30,11 +30,11 @@ type Authentication interface { IsPasswordValid(password string) error GeneratePasswordHash(password string) (string, error) CheckPlayerPassword(ctx context.Context, username string, password string) (bool, error) - LoginPlayer(ctx context.Context, username string, password string) + LoginPlayer(ctx context.Context, username string, password string) (model.AuthResult, error) } type DataFetching interface { - ListPlayerGames(ctx context.Context, gameId int64, playerId int64) ([]database.Game, error) + ListPlayerGames(ctx context.Context, playerId int64) ([]database.Game, error) GetSharedData(ctx context.Context, gameId int64) (model.SharedData, error) ListInteractions(ctx context.Context, gameId int64, count int) ([]database.Interaction, error) } diff --git a/internal/core/model/model.go b/internal/core/model/model.go index 3116a36..d457b02 100644 --- a/internal/core/model/model.go +++ b/internal/core/model/model.go @@ -1,6 +1,9 @@ package model -import "time" +import ( + "keep-it-up/internal/infrastructure/database" + "time" +) type SharedDataStatus string @@ -17,3 +20,8 @@ type SharedData struct { LastSavedAt *time.Time LastPausedAt *time.Time } + +type AuthResult struct { + Token string + Player database.Player +} From 50236c420195229b888c89d40925f63252f96e34 Mon Sep 17 00:00:00 2001 From: Fellipe Leonardo <112525075+neoRandom@users.noreply.github.com> Date: Mon, 17 Aug 2026 18:21:26 -0300 Subject: [PATCH 3/4] refactor(cli): remove game id from games argument list --- README.md | 2 +- internal/infrastructure/driver/cli.go | 16 ++++++---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c0efef5..61b9023 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Nouns: auth validate-passwd hash-passwd check-passwd - data games + data games shared interactions session save diff --git a/internal/infrastructure/driver/cli.go b/internal/infrastructure/driver/cli.go index cee4820..da3e616 100644 --- a/internal/infrastructure/driver/cli.go +++ b/internal/infrastructure/driver/cli.go @@ -22,7 +22,7 @@ var ( ErrWrongArgCount = errors.New("wrong number of arguments") ) -const usage = `keepitup — system management CLI +const usage = `keepitup --- system management CLI Usage: keepitup [args...] @@ -41,7 +41,7 @@ Nouns: auth validate-passwd hash-passwd check-passwd - data games + data games shared interactions session save @@ -363,18 +363,14 @@ func (c *CLI) runData(ctx context.Context, args []string) error { verb, rest := args[0], args[1:] switch verb { case "games": - if len(rest) != 2 { - return wrongArgs("data games", "data games ") - } - gameID, err := parseID(rest[0]) - if err != nil { - return fmt.Errorf("data games: %w", err) + if len(rest) != 1 { + return wrongArgs("data games", "data games ") } - playerID, err := parseID(rest[1]) + playerID, err := parseID(rest[0]) if err != nil { return fmt.Errorf("data games: %w", err) } - games, err := c.d.Data.ListPlayerGames(ctx, gameID, playerID) + games, err := c.d.Data.ListPlayerGames(ctx, playerID) if err != nil { return fmt.Errorf("data games: %w", err) } From c10c9f2937244f79d676fad94a2c76d51f376f77 Mon Sep 17 00:00:00 2001 From: Fellipe Leonardo <112525075+neoRandom@users.noreply.github.com> Date: Mon, 17 Aug 2026 18:29:16 -0300 Subject: [PATCH 4/4] docs: improve misleading README description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 61b9023..25d90dc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Keep It Up -A simple system that keeps an activity alive through periodic interaction and triggers an alert when it is left unattended for too long. +A system that coordinates periodic interactions across multiple devices and tracks when the next interaction is required. ## Tech Stack