bl2tools/bl2tools/cli.py
2022-04-21 14:02:32 -04:00

35 lines
882 B
Python

import click
from izzylib import Path
from .server import Server
from .watcher import SaveWatcher
@click.group
@click.option('--host', '-h', default='0.0.0.0', help='Address the web server should listen on')
@click.option('--port', '-p', default=8080, help='Port the web server should listen on')
@click.option('--save', '-s', type=Path, help='Path to Borderlands 2 game saves')
@click.option('--no-access-log', '-a', is_flag=True, default=True, help='Enable the server\'s access logging')
@click.pass_context
def cli(ctx, host, port, save, access_log):
ctx.obj = Server(host, port, save, access_log)
@cli.command('run')
@click.pass_context
def cli_run(ctx):
with SaveWatcher(ctx.obj):
ctx.obj.run()
@cli.command('debug')
@click.pass_context
def cli_debug(ctx):
print('Server:', ctx.obj)
print('Save path:', ctx.obj.save_path)
def main():
cli(prog_name='bl2tools')