Files

47 lines
1.6 KiB
Python
Raw Permalink Normal View History

2025-10-23 18:33:48 +02:00
#!/usr/bin/env python3
"""
Madomeda - Markdown Document Metadata Manager
"""
import argparse
import sys
from pathlib import Path
from datetime import datetime
from core.repository import Repository
from core.processor import FrontmatterProcessor
def main():
parser = argparse.ArgumentParser(description='Manage markdown frontmatter in git repositories')
parser.add_argument('--dir', type=Path, default=Path.cwd(), help='Git repository directory')
parser.add_argument('--template', type=str, default='default', help='Template name to use')
parser.add_argument('--ignore-paths', nargs='*', default=[], help='Relative paths to ignore')
parser.add_argument('--whatif', action='store_true', help='Dry run mode')
parser.add_argument('--no-confirm', action='store_true', help='Skip confirmation prompts')
parser.add_argument('--force', action='store_true', help='Force recreate all frontmatter')
parser.add_argument('--add-only', action='store_true', help='Only add missing fields, preserve existing keys')
args = parser.parse_args()
repo_path = args.dir.resolve()
if not (repo_path / '.git').exists():
print(f"Error: {repo_path} is not a git repository")
sys.exit(1)
repo = Repository(repo_path, args.ignore_paths)
processor = FrontmatterProcessor(
repo=repo,
template_name=args.template,
whatif=args.whatif,
no_confirm=args.no_confirm,
force=args.force,
add_only=args.add_only
)
processor.process()
print("\nProcessing complete!")
if __name__ == '__main__':
main()