geomotif.cli
¶
The geomotif command line.
Pure :mod:argparse, so the zero-dependency core stays that way::
geomotif list # every motif, by family
geomotif list --family fractal
geomotif show rose # docs, parameters, defaults
geomotif render rose --n 5 --samples 400 --out rose.svg
geomotif render spiral.golden --samples 300 --ease power:2.5 --out s.csv
geomotif render fractal.hilbert --depth 6 --out h.dxf --fit 800x800
geomotif render fractal.hilbert --out h.gif --motion draw-on --frames 60
geomotif render fractal.hilbert --out h.gif --frames 60 --hold 12
geomotif render mandala --out m.svg --paper a4 --optimize # for a plotter
geomotif render --spec my-design.json --out out.svg
geomotif explore rose --out rose.html # sliders for its parameters
geomotif gallery --out docs/gallery
geomotif demo
A motif's flags are generated from its dataclass fields, which is the point of
every builtin motif being one: --n, --depth, --center 0,0 and the
rest all come from the same declaration that drives describe() and the spec
format. Nothing is written twice.
Two things follow from generating flags rather than writing them.
Not every parameter can be said on a command line. A motif parameterized by
a Python function, by another motif, or by a point set has no sensible flag.
Those take their value from the motif's registered example instead, so every
motif in the catalog still renders -- geomotif render voronoi.cells gives
you the example's point set, and --inset still works on top of it.
A generic flag and a motif parameter share one namespace. The handful of
names this module claims are listed in :data:RESERVED; a motif parameter that
collides with one is not given a flag, and there is a test that no builtin
does. That is why the sampling options are --samples, --stride and
--ease rather than the more obvious words, which are all taken by motifs.
Functions:
| Name | Description |
|---|---|
main |
Run the command line and return the process exit code. |
build_parser |
Build the parser, with |
main
¶
Run the command line and return the process exit code.
Source code in src/geomotif/cli.py
build_parser
¶
build_parser(motif: MotifInfo | None = None) -> ArgumentParser
Build the parser, with motif's own flags added to render if given.
Source code in src/geomotif/cli.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |