Compare commits
6 Commits
7eafb1e68e
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
cf6d8712fb | ||
|
17c31ce6c9 | ||
|
d6ecb9e4c9 | ||
|
65f732e497 | ||
|
4690d13cb4 | ||
|
41692b7dc1 |
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,8 +1,4 @@
|
||||
bin
|
||||
include
|
||||
lib
|
||||
lib64
|
||||
pyvenv.cfg
|
||||
__pycache__
|
||||
dist/
|
||||
kumacli.egg-info
|
||||
.pytest_cache
|
||||
|
11
Makefile
11
Makefile
@@ -13,13 +13,8 @@ help:
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
@echo "Cleaning build artifacts..."
|
||||
rm -rf build/
|
||||
rm -rf dist/
|
||||
rm -rf src/kumacli.egg-info/
|
||||
rm -rf src/kumacli/__pycache__/
|
||||
rm -rf src/kumacli/cmd/__pycache__/
|
||||
find . -name "*.pyc" -delete
|
||||
find . -name "*.pyo" -delete
|
||||
rm -rf build/ dist/ src/kumacli.egg-info/
|
||||
find . -name "*.pyc" -o -name "*.pyo" -delete
|
||||
find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
|
||||
@echo "Clean complete."
|
||||
|
||||
@@ -42,7 +37,7 @@ test-deps:
|
||||
# Test the package
|
||||
test:
|
||||
@echo "Running tests..."
|
||||
python3 run_tests.py
|
||||
python3 -m pytest tests/ -v --tb=short
|
||||
|
||||
# Rebuild and reinstall (useful during development)
|
||||
dev: clean build
|
||||
|
14
pytest.ini
14
pytest.ini
@@ -1,14 +0,0 @@
|
||||
[tool:pytest]
|
||||
testpaths = tests
|
||||
python_files = test_*.py
|
||||
python_classes = Test*
|
||||
python_functions = test_*
|
||||
pythonpath = src
|
||||
addopts =
|
||||
-v
|
||||
--tb=short
|
||||
--strict-markers
|
||||
--disable-warnings
|
||||
filterwarnings =
|
||||
ignore::DeprecationWarning
|
||||
ignore::PendingDeprecationWarning
|
50
run_tests.py
50
run_tests.py
@@ -1,50 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
Test runner script for kumacli
|
||||
|
||||
Usage:
|
||||
python run_tests.py # Run all tests
|
||||
python run_tests.py --cov # Run tests with coverage
|
||||
python run_tests.py tests/test_info.py # Run specific test file
|
||||
"""
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
|
||||
def run_tests(args=None):
|
||||
"""Run pytest with optional arguments"""
|
||||
# Use python3 explicitly for compatibility
|
||||
cmd = ["python3", "-m", "pytest"]
|
||||
|
||||
if args:
|
||||
cmd.extend(args)
|
||||
else:
|
||||
cmd.extend(["tests/", "-v", "--tb=short"])
|
||||
|
||||
try:
|
||||
result = subprocess.run(cmd, check=True)
|
||||
return result.returncode
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Tests failed with exit code: {e.returncode}")
|
||||
return e.returncode
|
||||
except FileNotFoundError:
|
||||
print("pytest not found. Install with: pip install pytest")
|
||||
return 1
|
||||
|
||||
|
||||
def main():
|
||||
"""Main entry point"""
|
||||
if len(sys.argv) > 1:
|
||||
# Pass through command line arguments
|
||||
args = sys.argv[1:]
|
||||
else:
|
||||
args = None
|
||||
|
||||
exit_code = run_tests(args)
|
||||
sys.exit(exit_code)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
16
setup.py
16
setup.py
@@ -1,13 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import re
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
# Read version directly from version.py file without importing
|
||||
def get_version():
|
||||
version_file = os.path.join(os.path.dirname(__file__), 'src', 'kumacli', 'cmd', 'version.py')
|
||||
with open(version_file, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", content, re.M)
|
||||
if version_match:
|
||||
return version_match.group(1)
|
||||
raise RuntimeError("Unable to find version string.")
|
||||
|
||||
__version__ = get_version()
|
||||
|
||||
with open("README.md", "r", encoding="utf-8") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
setup(
|
||||
name="kumacli",
|
||||
version="1.3.0",
|
||||
version=__version__,
|
||||
author="Uptime Kuma CLI",
|
||||
description="A command-line interface for Uptime Kuma",
|
||||
long_description=long_description,
|
||||
|
@@ -2,10 +2,10 @@
|
||||
KumaCLI - A command-line interface for Uptime Kuma
|
||||
"""
|
||||
|
||||
__version__ = "1.0.0"
|
||||
from kumacli.kumacli import main
|
||||
from kumacli.cmd.version import __version__
|
||||
|
||||
__author__ = "KumaCLI Team"
|
||||
__email__ = "info@kumacli.com"
|
||||
|
||||
from kumacli.kumacli import main
|
||||
|
||||
__all__ = ["main"]
|
||||
|
16
src/kumacli/cmd/version.py
Normal file
16
src/kumacli/cmd/version.py
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Version command implementations for Uptime Kuma CLI."""
|
||||
|
||||
__version__ = "1.4.0"
|
||||
|
||||
|
||||
def setup_version_parser(subparsers):
|
||||
"""Setup version command parser"""
|
||||
version_parser = subparsers.add_parser("version", help="Show version information")
|
||||
return version_parser
|
||||
|
||||
|
||||
def handle_version_command(args, client): # pylint: disable=unused-argument
|
||||
"""Handle version command execution"""
|
||||
print(f"kumacli {__version__}")
|
||||
return True
|
@@ -11,6 +11,7 @@ try:
|
||||
from .cmd.monitor import setup_monitor_parser, handle_monitor_command
|
||||
from .cmd.maintenance import setup_maintenance_parser, handle_maintenance_command
|
||||
from .cmd.info import setup_info_parser, handle_info_command
|
||||
from .cmd.version import setup_version_parser, handle_version_command
|
||||
except ImportError:
|
||||
# Running directly, add parent directory to path
|
||||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
@@ -21,6 +22,7 @@ except ImportError:
|
||||
handle_maintenance_command,
|
||||
)
|
||||
from kumacli.cmd.info import setup_info_parser, handle_info_command
|
||||
from kumacli.cmd.version import setup_version_parser, handle_version_command
|
||||
|
||||
|
||||
def main():
|
||||
@@ -44,6 +46,7 @@ def main():
|
||||
setup_monitor_parser(subparsers)
|
||||
setup_maintenance_parser(subparsers)
|
||||
setup_info_parser(subparsers)
|
||||
setup_version_parser(subparsers)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -75,6 +78,8 @@ def main():
|
||||
success = handle_maintenance_command(args, client)
|
||||
elif args.resource == "info":
|
||||
success = handle_info_command(args, client)
|
||||
elif args.resource == "version":
|
||||
success = handle_version_command(args, client)
|
||||
else:
|
||||
parser.print_help()
|
||||
sys.exit(1)
|
||||
|
31
tests/test_version.py
Normal file
31
tests/test_version.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import pytest
|
||||
from unittest.mock import Mock
|
||||
|
||||
from kumacli.cmd.version import handle_version_command, __version__
|
||||
|
||||
|
||||
class TestVersionCommand:
|
||||
def test_handle_version_command(self, mock_client, capsys):
|
||||
"""Test version command handler"""
|
||||
# Setup
|
||||
mock_args = Mock()
|
||||
|
||||
# Execute
|
||||
result = handle_version_command(mock_args, mock_client)
|
||||
|
||||
# Verify
|
||||
assert result is True
|
||||
captured = capsys.readouterr()
|
||||
assert f"kumacli {__version__}" in captured.out
|
||||
|
||||
def test_version_is_defined(self):
|
||||
"""Test that version is properly defined"""
|
||||
assert __version__ is not None
|
||||
assert isinstance(__version__, str)
|
||||
assert len(__version__) > 0
|
||||
# Version should follow semantic versioning pattern (e.g., "1.4.0")
|
||||
parts = __version__.split(".")
|
||||
assert len(parts) >= 2 # At least major.minor
|
||||
assert all(part.isdigit() for part in parts) # All parts should be numeric
|
Reference in New Issue
Block a user