refactor: Remove deprecated query and schema commands and update all tests
Some checks failed
Test Suite / unit-tests (3.11) (push) Has been cancelled
Test Suite / unit-tests (3.12) (push) Has been cancelled
Test Suite / integration-tests (push) Has been cancelled
Test Suite / e2e-tests (push) Has been cancelled
Test Suite / performance-tests (push) Has been cancelled
Test Suite / code-quality (push) Has been cancelled
Test Suite / security-scan (push) Has been cancelled
Test Suite / test-summary (push) Has been cancelled
Some checks failed
Test Suite / unit-tests (3.11) (push) Has been cancelled
Test Suite / unit-tests (3.12) (push) Has been cancelled
Test Suite / integration-tests (push) Has been cancelled
Test Suite / e2e-tests (push) Has been cancelled
Test Suite / performance-tests (push) Has been cancelled
Test Suite / code-quality (push) Has been cancelled
Test Suite / security-scan (push) Has been cancelled
Test Suite / test-summary (push) Has been cancelled
- Remove deprecated 'query' command (replaced by 'db-query') - Remove deprecated 'schema' command (replaced by 'db-schema') - Remove 4 obsolete tests that tested deprecated functionality - Update all remaining tests to use new db-prefixed command names - CLI now has clean, consistent command structure with proper prefixes - All 478 tests passing after cleanup This completes the CLI consistency convention implementation where all subsystem commands follow the "*-stats" pattern and use proper prefixes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
113
markitect/cli.py
113
markitect/cli.py
@@ -756,67 +756,6 @@ def modify(config, file_path, add_section, section_content, section_level, updat
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.argument('sql', type=str)
|
||||
@click.option('--format', '-f', type=click.Choice(['table', 'json', 'yaml', 'simple']), default=lambda: get_default_format(['table', 'json', 'yaml', 'simple']), help='Output format')
|
||||
@pass_config
|
||||
def query(config, sql, format):
|
||||
"""
|
||||
Execute SQL query against the database.
|
||||
|
||||
DEPRECATED: Use 'db-query' instead. This command will be removed in a future version.
|
||||
|
||||
Execute read-only SQL queries to explore and analyze document metadata.
|
||||
Only SELECT and WITH statements are allowed for security.
|
||||
|
||||
SQL: SQL query to execute (SELECT statements only)
|
||||
|
||||
Examples:
|
||||
markitect db-query "SELECT filename, created_at FROM markdown_files"
|
||||
markitect db-query "SELECT COUNT(*) as total FROM markdown_files" --format json
|
||||
markitect db-query "SELECT * FROM markdown_files WHERE filename LIKE '%.md'" --format yaml
|
||||
"""
|
||||
# Show deprecation warning (unless in legacy mode)
|
||||
if not LegacyMode.should_suppress_warnings():
|
||||
emit_deprecation_warning(
|
||||
"The 'query' command is deprecated. Please use 'db-query' instead. "
|
||||
"This command will be removed in a future version."
|
||||
)
|
||||
|
||||
try:
|
||||
if config['verbose']:
|
||||
click.echo(f"Executing query: {sql}", err=True)
|
||||
|
||||
db_manager = config['db_manager']
|
||||
|
||||
# Execute the query
|
||||
results = db_manager.execute_query(sql)
|
||||
|
||||
if not results:
|
||||
if format == 'json':
|
||||
click.echo('[]')
|
||||
elif format == 'yaml':
|
||||
click.echo('[]')
|
||||
else:
|
||||
click.echo("No results found.")
|
||||
return
|
||||
|
||||
# Format and display results
|
||||
formatted_output = format_output(results, format)
|
||||
click.echo(formatted_output)
|
||||
|
||||
if config['verbose']:
|
||||
click.echo(f"Query returned {len(results)} result(s)", err=True)
|
||||
|
||||
except ValueError as e:
|
||||
click.echo(f"Query error: {e}", err=True)
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
click.echo(f"Database error: {e}", err=True)
|
||||
if config['verbose']:
|
||||
import traceback
|
||||
click.echo(traceback.format_exc(), err=True)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@cli.command('db-query')
|
||||
@@ -873,58 +812,6 @@ def db_query(config, sql, format):
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option('--format', '-f', type=click.Choice(['table', 'json', 'yaml', 'simple']), default=lambda: get_default_format(['table', 'json', 'yaml', 'simple']), help='Output format')
|
||||
@pass_config
|
||||
def schema(config, format):
|
||||
"""
|
||||
Show database schema and table structure.
|
||||
|
||||
DEPRECATED: Use 'db-schema' instead. This command will be removed in a future version.
|
||||
|
||||
Display the structure of all tables in the database, including
|
||||
column names, types, and constraints.
|
||||
|
||||
Examples:
|
||||
markitect db-schema
|
||||
markitect db-schema --format json
|
||||
markitect db-schema --format yaml
|
||||
"""
|
||||
# Show deprecation warning (unless in legacy mode)
|
||||
if not LegacyMode.should_suppress_warnings():
|
||||
emit_deprecation_warning(
|
||||
"The 'schema' command is deprecated. Please use 'db-schema' instead. "
|
||||
"This command will be removed in a future version."
|
||||
)
|
||||
|
||||
try:
|
||||
if config['verbose']:
|
||||
click.echo("Retrieving database schema...", err=True)
|
||||
|
||||
db_manager = config['db_manager']
|
||||
|
||||
# Get schema information
|
||||
schema_info = db_manager.get_schema()
|
||||
|
||||
if not schema_info:
|
||||
click.echo("No tables found in database.")
|
||||
return
|
||||
|
||||
# Format and display schema
|
||||
formatted_output = format_output(schema_info, format)
|
||||
click.echo(formatted_output)
|
||||
|
||||
if config['verbose']:
|
||||
table_count = len(schema_info)
|
||||
click.echo(f"Schema contains {table_count} table(s)", err=True)
|
||||
|
||||
except Exception as e:
|
||||
click.echo(f"Schema error: {e}", err=True)
|
||||
if config['verbose']:
|
||||
import traceback
|
||||
click.echo(traceback.format_exc(), err=True)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@cli.command('db-schema')
|
||||
@click.option('--format', '-f', type=click.Choice(['table', 'json', 'yaml', 'simple']), default=lambda: get_default_format(['table', 'json', 'yaml', 'simple']), help='Output format')
|
||||
|
||||
Reference in New Issue
Block a user