Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/memu/server/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Server module for MemU."""
85 changes: 85 additions & 0 deletions src/memu/server/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"""CLI entry point for memu-server."""

from __future__ import annotations

import argparse
import sys
from typing import Sequence


def main(args: Sequence[str] | None = None) -> int:
"""Main entry point for memu-server CLI."""
parser = argparse.ArgumentParser(
prog="memu-server",
description="MemU Server - AI Memory and Conversation Management Framework",
)

parser.add_argument(
"--version",
action="version",
version="%(prog)s 1.4.0",
)

subparsers = parser.add_subparsers(dest="command", help="Available commands")

# Start command
start_parser = subparsers.add_parser(
"start",
help="Start the MemU server",
)
start_parser.add_argument(
"--host",
default="127.0.0.1",
help="Host to bind to (default: 127.0.0.1)",
)
start_parser.add_argument(
"--port",
type=int,
default=8000,
help="Port to bind to (default: 8000)",
)
start_parser.add_argument(
"--config",
type=str,
help="Path to configuration file",
)

# Info command
info_parser = subparsers.add_parser(
"info",
help="Show system information",
)

parsed = parser.parse_args(args)

if parsed.command == "start":
print("🧠 Starting MemU server...")
print(f" Host: {parsed.host}")
print(f" Port: {parsed.port}")
if parsed.config:
print(f" Config: {parsed.config}")
print()
print("⚠️ Note: Full server implementation is in development.")
print(" Currently, use MemoryService programmatically:")
print()
print(" from memu import MemoryService")
print(" service = MemoryService()")
print()
return 0

elif parsed.command == "info":
print("🧠 MemU - AI Memory Framework")
print(" Version: 1.4.0")
print(" Python: >=3.13")
print()
print(" For documentation, visit:")
print(" https://github.com/NevaMind-AI/MemU")
return 0

else:
parser.print_help()
return 0


if __name__ == "__main__":
sys.exit(main())
62 changes: 62 additions & 0 deletions tests/test_server_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""Tests for server CLI module."""

import pytest
from memu.server.cli import main


class TestServerCLI:
"""Test suite for memu-server CLI."""

def test_cli_help(self, capsys):
"""Test that CLI shows help without error."""
with pytest.raises(SystemExit) as exc_info:
main(["--help"])

assert exc_info.value.code == 0
captured = capsys.readouterr()
assert "MemU Server" in captured.out

def test_cli_version(self, capsys):
"""Test that CLI shows version."""
with pytest.raises(SystemExit) as exc_info:
main(["--version"])

assert exc_info.value.code == 0
captured = capsys.readouterr()
assert "1.4.0" in captured.out

def test_cli_info(self, capsys):
"""Test info command."""
result = main(["info"])

assert result == 0
captured = capsys.readouterr()
assert "MemU" in captured.out
assert "1.4.0" in captured.out

def test_cli_start(self, capsys):
"""Test start command."""
result = main(["start", "--host", "0.0.0.0", "--port", "8080"])

assert result == 0
captured = capsys.readouterr()
assert "Starting MemU server" in captured.out
assert "0.0.0.0" in captured.out
assert "8080" in captured.out

def test_cli_start_default(self, capsys):
"""Test start command with default values."""
result = main(["start"])

assert result == 0
captured = capsys.readouterr()
assert "127.0.0.1" in captured.out
assert "8000" in captured.out

def test_cli_no_args_shows_help(self, capsys):
"""Test that running without args shows help."""
result = main([])

assert result == 0
captured = capsys.readouterr()
assert "usage:" in captured.out