diff --git a/rsbbs/args.py b/rsbbs/args.py new file mode 100644 index 0000000..744ecf2 --- /dev/null +++ b/rsbbs/args.py @@ -0,0 +1,80 @@ +#!/usr/bin/env python +# +# Really Simple BBS - a really simple BBS for ax.25 packet radio. +# Copyright (C) 2023 John Burwell +# +# 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 . + +import argparse +import sys + +from rsbbs import __version__ + + +def parse_args(): + # Parse and handle the system invocation arguments + argv_parser = argparse.ArgumentParser( + description=("The BBS for ax.25 and packet radio " + "that is really simple.")) + + # Configure args: + args_list = [ + # [ short, long, action, default, dest, help, required ] + ['-d', '--debug', 'store_true', None, 'debug', + 'Enable debugging output to stdout', False], + # ['-s', '--calling-station', 'store', 'N0CALL', 'calling_station', + # 'Callsign of the calling station', True], + ['-f', '--config-file', 'store', None, 'config_file', + 'Path to config.yaml file', False], + ] + for arg in args_list: + argv_parser.add_argument( + arg[0], arg[1], action=arg[2], default=arg[3], dest=arg[4], + help=arg[5], required=arg[6]) + + group = argv_parser.add_mutually_exclusive_group(required=True) + + # Log level: + argv_parser.add_argument( + '--log-level', + action='store', + default='INFO', + dest='log_level', + help="Logging level") + + # Show config option: + group.add_argument( + '--show-config', + action='store_true', + default=None, + dest='show_config', + help="Show the configuration and exit") + + # Calling station: + group.add_argument( + '-s', + '--calling-station', + action='store', + default='N0CALL', + dest='calling_station', + help="Callsign of the calling station") + + # Version arg is special: + argv_parser.add_argument( + '-v', '--version', + action='version', + version=f"{argv_parser.prog} version {__version__}") + + # Parse the args from the system + return argv_parser.parse_args(sys.argv[1:]) diff --git a/rsbbs/rsbbs.py b/rsbbs/rsbbs.py index 90a0cbb..41141e8 100755 --- a/rsbbs/rsbbs.py +++ b/rsbbs/rsbbs.py @@ -16,70 +16,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import argparse import logging -import sys from rsbbs import __version__ from rsbbs import Config, Console, Controller, Logger - -def parse_args(): - # Parse and handle the system invocation arguments - argv_parser = argparse.ArgumentParser( - description=("The BBS for ax.25 and packet radio " - "that is really simple.")) - - # Configure args: - args_list = [ - # [ short, long, action, default, dest, help, required ] - ['-d', '--debug', 'store_true', None, 'debug', - 'Enable debugging output to stdout', False], - # ['-s', '--calling-station', 'store', 'N0CALL', 'calling_station', - # 'Callsign of the calling station', True], - ['-f', '--config-file', 'store', None, 'config_file', - 'Path to config.yaml file', False], - ] - for arg in args_list: - argv_parser.add_argument( - arg[0], arg[1], action=arg[2], default=arg[3], dest=arg[4], - help=arg[5], required=arg[6]) - - group = argv_parser.add_mutually_exclusive_group(required=True) - - # Log level: - argv_parser.add_argument( - '--log-level', - action='store', - default='INFO', - dest='log_level', - help="Logging level") - - # Show config option: - group.add_argument( - '--show-config', - action='store_true', - default=None, - dest='show_config', - help="Show the configuration and exit") - - # Calling station: - group.add_argument( - '-s', - '--calling-station', - action='store', - default='N0CALL', - dest='calling_station', - help="Callsign of the calling station") - - # Version arg is special: - argv_parser.add_argument( - '-v', '--version', - action='version', - version=f"{argv_parser.prog} version {__version__}") - - # Parse the args from the system - return argv_parser.parse_args(sys.argv[1:]) +from rsbbs.args import parse_args def main():