cmdline.py (3006B)
1 # cmdline.py 2 # 3 # Copyright (C) 2017 Brian C. Lane 4 # 5 # This program is free software; you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation; either version 2 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 import argparse 18 19 version = "DEVEL" 20 21 def parser(max_cores): 22 """ Return the ArgumentParser""" 23 24 parser = argparse.ArgumentParser(description="Motion Camera Web Interface") 25 26 required = parser.add_argument_group("required arguments") 27 required.add_argument("-c", "--config", 28 help="Path to motion.conf", 29 required=True, metavar="MOTION") 30 31 # optional arguments 32 optional = parser.add_argument_group("optional arguments") 33 optional.add_argument("-H", "--host", 34 help="Host or IP to bind to (127.0.0.1)", 35 metavar="HOSTNAME|IP", 36 default="127.0.0.1") 37 optional.add_argument("-P", "--port", 38 help="Post to bind to (8000)", 39 metavar="PORT", 40 default=8000) 41 optional.add_argument("-n", "--noqueue", 42 help="Do not process queue events", 43 action="store_true", default=False) 44 optional.add_argument("-l", "--log", 45 help="Path to logfile (/var/tmp/strix.log)", 46 metavar="LOGFILE", 47 default="/var/tmp/strix.log") 48 optional.add_argument("--debug", 49 help="Output debug information", 50 action="store_true", default=False) 51 optional.add_argument("--max-cores", 52 help="Maximum cores to use for ffmpeg", 53 metavar="MAXCORES", 54 type=int, 55 default=max_cores) 56 optional.add_argument("--keep-days", 57 help="How many days of events to keep", 58 metavar="KEEPDAYS", 59 type=int, 60 default=45) 61 optional.add_argument("--check-cache", 62 help="How often to check cache for expired events (in minutes)", 63 metavar="CHECKCACHE", 64 type=int, 65 default=60) 66 67 68 # add the show version option 69 parser.add_argument("-V", help="show program's version number and exit", 70 action="version", version=version) 71 72 return parser