#!/usr/bin/env python

#
# Project Librarian: Brandon Piotrzkowski
#              Graduate Student
#              UW-Milwaukee Department of Physics
#              Center for Gravitation & Cosmology
#              <brandon.piotrzkowski@ligo.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

"""
Script to generate macrofile for the speed of gravity manuscript.
"""
__author__ = "Brandon Piotrzkowski <brandon.piotrzkowski@ligo.org>"

import argparse
from gracedb_sdk import Client

from SoG.tex.generate_upload_pdf import generate_macrofile


#  Command line options.
parser = argparse.ArgumentParser(description='Generate macrofile using GraceDB ID')
parser.add_argument("-i", "--graceid", metavar="(S,MS)XXXXXX",
                    default=None,
                    help="GraceDB ID of superevent (required)"),
parser.add_argument("-g", "--gracedb_url", metavar="https://gracedb.ligo.org/api/",
                    default="https://gracedb.ligo.org/api/",
                    help="Gracedb url"),
parser.add_argument("-p", "--output_path", metavar="./",
                    default="./",
                    help="Output file path")
args = parser.parse_args()
print(args)

#  Load gracedb_sdk client
gracedb = Client(args.gracedb_url)

#  Run function from repository
generate_macrofile(args.graceid, gracedb=gracedb, tmppath=args.output_path)