mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Single-source version number
This commit is contained in:
parent
d565df27b3
commit
93a5a94dab
@ -1,43 +0,0 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from .config import Config, ConfigDumpException, ConfigLoadException
|
||||
from .pferd import Pferd
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--config", "-c",
|
||||
type=Path,
|
||||
metavar="PATH",
|
||||
help="specify custom config file path",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dump-config",
|
||||
nargs="?",
|
||||
const=True,
|
||||
type=Path,
|
||||
metavar="PATH",
|
||||
help="dump current configuration to a file and exit."
|
||||
" Uses default config file path if no path is specified",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
config_parser = Config.load_parser(args.config)
|
||||
config = Config(config_parser)
|
||||
except ConfigLoadException:
|
||||
exit(1)
|
||||
|
||||
if args.dump_config:
|
||||
path = None if args.dump_config is True else args.dump_config
|
||||
try:
|
||||
config.dump(path)
|
||||
except ConfigDumpException:
|
||||
exit(1)
|
||||
exit()
|
||||
|
||||
pferd = Pferd(config)
|
||||
asyncio.run(pferd.run())
|
43
PFERD/__main__.py
Normal file
43
PFERD/__main__.py
Normal file
@ -0,0 +1,43 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
from pathlib import Path
|
||||
|
||||
from .config import Config, ConfigDumpException, ConfigLoadException
|
||||
from .pferd import Pferd
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--config", "-c",
|
||||
type=Path,
|
||||
metavar="PATH",
|
||||
help="specify custom config file path",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--dump-config",
|
||||
nargs="?",
|
||||
const=True,
|
||||
type=Path,
|
||||
metavar="PATH",
|
||||
help="dump current configuration to a file and exit."
|
||||
" Uses default config file path if no path is specified",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
config_parser = Config.load_parser(args.config)
|
||||
config = Config(config_parser)
|
||||
except ConfigLoadException:
|
||||
exit(1)
|
||||
|
||||
if args.dump_config:
|
||||
path = None if args.dump_config is True else args.dump_config
|
||||
try:
|
||||
config.dump(path)
|
||||
except ConfigDumpException:
|
||||
exit(1)
|
||||
exit()
|
||||
|
||||
pferd = Pferd(config)
|
||||
asyncio.run(pferd.run())
|
1
PFERD/version.py
Normal file
1
PFERD/version.py
Normal file
@ -0,0 +1 @@
|
||||
__version__ = "3.0.0"
|
Loading…
Reference in New Issue
Block a user