pydantic model generator for atproto lexicons

fix cache dir to use XDG on all unix, add --show-cache flag (#3)

- use ~/.cache/pmgfal (XDG standard) on all unix-like systems including macOS
- add --show-cache flag to print cache directory and exit
- update README: change suggested output dir from src/models to src/atproto
to avoid confusion with ORM schemas

๐Ÿค– Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>

authored by zzstoatzz.io

Claude and committed by
GitHub
46a9285d 9a7f5fac

+19 -12
+8 -9
README.md
··· 17 17 uvx pmgfal 18 18 19 19 # explicit paths 20 - uvx pmgfal ./lexicons -o ./src/models 20 + uvx pmgfal ./lexicons -o ./src/atproto 21 21 22 22 # filter by namespace 23 23 uvx pmgfal -p fm.plyr ··· 31 31 pmgfal caches generated models based on a hash of your lexicon files. on subsequent runs with unchanged lexicons, it copies from cache instead of regenerating. 32 32 33 33 cache location: 34 - - macos: `~/Library/Caches/pmgfal/` 35 - - linux: `~/.cache/pmgfal/` 34 + - unix (linux/macos/bsd): `~/.cache/pmgfal/` (or `$XDG_CACHE_HOME/pmgfal/`) 36 35 - windows: `%LOCALAPPDATA%/pmgfal/` 37 36 38 37 the cache key includes: ··· 72 71 โ”‚ โ”œโ”€โ”€ like.json 73 72 โ”‚ โ””โ”€โ”€ comment.json 74 73 โ”œโ”€โ”€ src/ 75 - โ”‚ โ””โ”€โ”€ models/ 74 + โ”‚ โ””โ”€โ”€ atproto/ 76 75 โ”‚ โ””โ”€โ”€ .gitkeep 77 76 โ””โ”€โ”€ pyproject.toml 78 77 ``` ··· 80 79 ### 2. generate models 81 80 82 81 ```bash 83 - uvx pmgfal ./lexicons -o ./src/models -p fm.plyr 82 + uvx pmgfal ./lexicons -o ./src/atproto -p fm.plyr 84 83 ``` 85 84 86 85 ### 3. use in your code 87 86 88 87 ```python 89 - from your_project.models import FmPlyrTrack, FmPlyrLike 88 + from your_project.atproto import FmPlyrTrack, FmPlyrLike 90 89 91 90 track = FmPlyrTrack( 92 91 uri="at://did:plc:xyz/fm.plyr.track/123", ··· 106 105 hooks: 107 106 - id: pmgfal 108 107 name: generate atproto models 109 - entry: uvx pmgfal ./lexicons -o ./src/models -p fm.plyr 108 + entry: uvx pmgfal ./lexicons -o ./src/atproto -p fm.plyr 110 109 language: system 111 110 files: ^lexicons/.*\.json$ 112 111 pass_filenames: false ··· 117 116 ```just 118 117 # justfile 119 118 generate: 120 - uvx pmgfal ./lexicons -o ./src/models -p fm.plyr 119 + uvx pmgfal ./lexicons -o ./src/atproto -p fm.plyr 121 120 ``` 122 121 123 122 **option c: github actions** ··· 125 124 ```yaml 126 125 # .github/workflows/ci.yml 127 126 - name: generate models 128 - run: uvx pmgfal ./lexicons -o ./src/models -p fm.plyr 127 + run: uvx pmgfal ./lexicons -o ./src/atproto -p fm.plyr 129 128 ``` 130 129 131 130 caching ensures regeneration is fast (~0.3s for 300 lexicons) when files haven't changed.
+11 -3
python/pmgfal/__init__.py
··· 70 70 71 71 def get_cache_dir() -> Path: 72 72 """get the user cache directory for pmgfal.""" 73 - if sys.platform == "darwin": 74 - base = Path.home() / "Library" / "Caches" 75 - elif sys.platform == "win32": 73 + if sys.platform == "win32": 76 74 base = Path(os.environ.get("LOCALAPPDATA", Path.home() / "AppData" / "Local")) 77 75 else: 76 + # XDG standard for all unix-like systems (linux, macos, bsd) 78 77 base = Path(os.environ.get("XDG_CACHE_HOME", Path.home() / ".cache")) 79 78 return base / "pmgfal" 80 79 ··· 162 161 action="version", 163 162 version=f"%(prog)s {__version__}", 164 163 ) 164 + parser.add_argument( 165 + "--show-cache", 166 + action="store_true", 167 + help="print cache directory path and exit", 168 + ) 165 169 166 170 parsed = parser.parse_args(args) 171 + 172 + if parsed.show_cache: 173 + print(get_cache_dir()) 174 + return 0 167 175 168 176 temp_dir = None 169 177 try: