fc5: export script — add --output FILE flag for Swarm one-shot service use
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -114,6 +114,16 @@ def _export_series_pages():
|
||||
|
||||
|
||||
def main() -> None:
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument(
|
||||
"--output",
|
||||
default=None,
|
||||
help="Write JSON to this path instead of stdout (use this when "
|
||||
"running inside a Swarm service that writes to a bind-mount).",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
app = create_app()
|
||||
with app.app_context():
|
||||
export = {
|
||||
@@ -125,6 +135,16 @@ def main() -> None:
|
||||
"image_tag_associations": _export_image_tag_associations(),
|
||||
"series_pages": _export_series_pages(),
|
||||
}
|
||||
|
||||
if args.output:
|
||||
from pathlib import Path
|
||||
out_path = Path(args.output)
|
||||
out_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
out_path.write_text(json.dumps(export, indent=2) + "\n")
|
||||
print(f"wrote {out_path} ({len(export['tags'])} tags, "
|
||||
f"{len(export['image_tag_associations'])} associations)",
|
||||
file=sys.stderr)
|
||||
else:
|
||||
json.dump(export, sys.stdout, indent=2)
|
||||
sys.stdout.write("\n")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user