mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Implement --version flag
This commit is contained in:
parent
5916626399
commit
92886fb8d8
@ -6,8 +6,14 @@ from pathlib import Path
|
|||||||
from .config import Config, ConfigDumpException, ConfigLoadException
|
from .config import Config, ConfigDumpException, ConfigLoadException
|
||||||
from .output_dir import OnConflict, Redownload
|
from .output_dir import OnConflict, Redownload
|
||||||
from .pferd import Pferd
|
from .pferd import Pferd
|
||||||
|
from .version import NAME, VERSION
|
||||||
|
|
||||||
GENERAL_PARSER = argparse.ArgumentParser(add_help=False)
|
GENERAL_PARSER = argparse.ArgumentParser(add_help=False)
|
||||||
|
GENERAL_PARSER.add_argument(
|
||||||
|
"--version",
|
||||||
|
action="store_true",
|
||||||
|
help="print version and exit"
|
||||||
|
)
|
||||||
GENERAL_PARSER.add_argument(
|
GENERAL_PARSER.add_argument(
|
||||||
"--config", "-c",
|
"--config", "-c",
|
||||||
type=Path,
|
type=Path,
|
||||||
@ -211,6 +217,10 @@ def prune_crawlers(
|
|||||||
def main() -> None:
|
def main() -> None:
|
||||||
args = PARSER.parse_args()
|
args = PARSER.parse_args()
|
||||||
|
|
||||||
|
if args.version:
|
||||||
|
print(f"{NAME} {VERSION}")
|
||||||
|
exit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
config = Config(load_parser(args))
|
config = Config(load_parser(args))
|
||||||
except ConfigLoadException:
|
except ConfigLoadException:
|
||||||
|
@ -14,7 +14,7 @@ from .limiter import Limiter
|
|||||||
from .logging import ProgressBar, log
|
from .logging import ProgressBar, log
|
||||||
from .output_dir import FileSink, OnConflict, OutputDirectory, Redownload
|
from .output_dir import FileSink, OnConflict, OutputDirectory, Redownload
|
||||||
from .transformer import Transformer
|
from .transformer import Transformer
|
||||||
from .version import __version__
|
from .version import NAME, VERSION
|
||||||
|
|
||||||
|
|
||||||
class CrawlWarning(Exception):
|
class CrawlWarning(Exception):
|
||||||
@ -275,7 +275,7 @@ class HttpCrawler(Crawler):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
async with aiohttp.ClientSession(
|
async with aiohttp.ClientSession(
|
||||||
headers={"User-Agent": f"pferd/{__version__}"},
|
headers={"User-Agent": f"{NAME}/{VERSION}"},
|
||||||
cookie_jar=cookie_jar,
|
cookie_jar=cookie_jar,
|
||||||
) as session:
|
) as session:
|
||||||
self.session = session
|
self.session = session
|
||||||
|
@ -1 +1,2 @@
|
|||||||
__version__ = "3.0.0"
|
NAME = "PFERD"
|
||||||
|
VERSION = "3.0.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user