From: Guillaume Pellerin Date: Fri, 22 Aug 2025 10:16:52 +0000 (+0200) Subject: use argparse X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=73b9e5d12044a1a2efbfccd45d05a73a51c16ae4;p=deefuzzer.git use argparse --- diff --git a/scripts/deefuzzer b/scripts/deefuzzer index e728514..50817ad 100755 --- a/scripts/deefuzzer +++ b/scripts/deefuzzer @@ -1,56 +1,18 @@ #!/usr/bin/python3 -import os -import sys -import shout -import datetime -import platform +import argparse import deefuzzer -year = datetime.datetime.now().strftime("%Y") -platform_system = platform.system() - - -def prog_info(): - desc = """ deefuzzer : easy and instant media streaming tool - version : %s - running on system : %s - - Copyright (c) 2007-%s Guillaume Pellerin - All rights reserved. - - This software is licensed as described in the file COPYING, which - you should have received as part of this distribution. The terms - are also available at https://github.com/yomguy/DeeFuzzer/blob/master/LICENSE - - depends: python, python-dev, python-xml, python-shout | shout-python, libshout3, - libshout3-dev, python-mutagen, python-pycurl - - recommends: icecast2, python-twitter, python-liblo | pyliblo (>= 0.26) - - Usage : deefuzzer [file] - - where [file] is the path for a XML config file. - - Edit an example in example/deefuzzer.xml - and then start one or more stations: - - $ deefuzzer example/deefuzzer.xml - - see http://github.com/yomguy/DeeFuzzer for more details and debugging. - """ - - return desc % (deefuzzer.__version__, platform_system, year) - +from deefuzzer.version import __version__ def main(): - if len(sys.argv) >= 2: - d = deefuzzer.core.DeeFuzzer(sys.argv[-1]) - d.start() - else: - text = prog_info() - sys.exit(text) + parser = argparse.ArgumentParser() + parser.add_argument('-v', '--version', help='show version', action="version", version='%(prog)s ' + __version__) + parser.add_argument('config_file', type=str, help='config file (YAML, XML or JSON)') + args = parser.parse_args() + d = deefuzzer.core.DeeFuzzer(**args) + d.start() if __name__ == '__main__': main()