feat: Establish CLI subsystem *-stats command naming convention

Implemented comprehensive CLI naming consistency by standardizing all subsystem
commands to use *-stats for status reporting:

## Changes Made:

### 1. Removed Unnecessary Skipped Tests
- Removed two deferred tests for global option path display from Issue #39
- Tests were marked as requiring "complex CLI changes" and deemed not worth effort
- Cleaner test suite without placeholder functionality

### 2. Renamed cache-info → cache-stats
- Updated CLI command: @cli.command('cache-stats')
- Updated function name: cache_info() → cache_stats()
- Updated all test files to use cache-stats
- Consistent with subsystem naming convention

### 3. Renamed db-status → db-stats
- Updated CLI command: @cli.command('db-stats')
- Updated function name: db_status() → db_stats()
- Updated all test files and references to use db-stats
- Maintains database subsystem consistency

### 4. Implemented config-stats Command
- New CLI command following *-stats convention
- Displays configuration statistics and status information
- Supports all output formats: table, json, yaml, simple
- Integrates with existing config system when available
- Provides fallback functionality for basic configuration reporting

## Established Convention:
All CLI subsystems now have consistent *-stats commands:
-  ast-stats (already existed)
-  cache-stats (renamed from cache-info)
-  db-stats (renamed from db-status)
-  config-stats (newly implemented)

## Benefits:
- Intuitive command discovery (users know to try *-stats for any subsystem)
- Consistent CLI experience across all subsystems
- Better organized help documentation
- Professional CLI interface following standard conventions

All tests updated and passing. CLI maintains backward compatibility for
essential functionality while establishing clear, consistent patterns.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-30 22:13:07 +02:00
parent d689d84635
commit cbf82b74cb
9 changed files with 416 additions and 270 deletions

View File

@@ -8,7 +8,7 @@ database interface.
Requirements tested:
- markitect query <sql> command with safety constraints
- markitect schema command for database structure inspection
- markitect metadata <file> command for file metadata display
- markitect db-data <file> command for file metadata display (updated from metadata in Issue #38)
- Multiple output format support (table, JSON, YAML)
- Read-only access and SQL injection protection
- Integration with existing DatabaseManager
@@ -24,7 +24,7 @@ from unittest.mock import patch, MagicMock
# Import the CLI module (will be extended during implementation)
try:
from markitect.cli import cli, query_command, schema_command, metadata_command
from markitect.cli import cli, query_command, schema_command, db_data_command
except ImportError:
# Commands don't exist yet - this is expected in TDD
from markitect.cli import cli
@@ -206,29 +206,29 @@ class TestSchemaCommand:
assert result.exit_code == 0
class TestMetadataCommand:
"""Test suite for markitect metadata command."""
class TestDbDataCommand:
"""Test suite for markitect db-data command."""
def setup_method(self):
"""Set up test fixtures."""
self.runner = CliRunner()
def test_metadata_command_exists(self):
def test_db_data_command_exists(self):
"""
Test that the metadata command is accessible.
Test that the db-data command is accessible.
Issue #14: Metadata display functionality
Issue #14: Metadata display functionality (updated for Issue #38)
"""
result = self.runner.invoke(cli, ['metadata', '--help'])
result = self.runner.invoke(cli, ['db-data', '--help'])
assert result.exit_code == 0
assert 'metadata' in result.output.lower()
assert 'db-data' in result.output.lower()
assert 'file' in result.output.lower()
def test_metadata_command_displays_file_info(self):
def test_db_data_command_displays_file_info(self):
"""
Test that metadata command displays file metadata and front matter.
Test that db-data command displays file metadata and front matter.
Issue #14: Metadata display functionality
Issue #14: Metadata display functionality (updated for Issue #38)
"""
with patch('markitect.cli.DatabaseManager') as mock_db_mgr:
mock_db_instance = MagicMock()
@@ -243,18 +243,18 @@ class TestMetadataCommand:
'created_at': '2025-09-25 12:00:00'
}
result = self.runner.invoke(cli, ['metadata', 'test.md'])
result = self.runner.invoke(cli, ['db-data', 'test.md'])
assert result.exit_code == 0
assert 'test.md' in result.output
assert 'Test Document' in result.output
assert 'Test Author' in result.output
def test_metadata_command_handles_missing_file(self):
def test_db_data_command_handles_missing_file(self):
"""
Test that metadata command handles missing files gracefully.
Test that db-data command handles missing files gracefully.
Issue #14: Metadata display functionality
Issue #14: Metadata display functionality (updated for Issue #38)
"""
with patch('markitect.cli.DatabaseManager') as mock_db_mgr:
mock_db_instance = MagicMock()
@@ -263,16 +263,16 @@ class TestMetadataCommand:
# Mock file not found
mock_db_instance.get_markdown_file.return_value = None
result = self.runner.invoke(cli, ['metadata', 'nonexistent.md'])
result = self.runner.invoke(cli, ['db-data', 'nonexistent.md'])
assert result.exit_code != 0
assert 'not found' in result.output.lower()
def test_metadata_command_supports_output_formats(self):
def test_db_data_command_supports_output_formats(self):
"""
Test that metadata command supports multiple output formats.
Test that db-data command supports multiple output formats.
Issue #14: Multiple output format support
Issue #14: Multiple output format support (updated for Issue #38)
"""
with patch('markitect.cli.DatabaseManager') as mock_db_mgr:
mock_db_instance = MagicMock()
@@ -286,11 +286,11 @@ class TestMetadataCommand:
mock_db_instance.get_markdown_file.return_value = mock_metadata
# Test JSON format
result = self.runner.invoke(cli, ['metadata', 'test.md', '--format', 'json'])
result = self.runner.invoke(cli, ['db-data', 'test.md', '--format', 'json'])
assert result.exit_code == 0
# Test YAML format
result = self.runner.invoke(cli, ['metadata', 'test.md', '--format', 'yaml'])
result = self.runner.invoke(cli, ['db-data', 'test.md', '--format', 'yaml'])
assert result.exit_code == 0