From a6713cfaa15b039a5b67d06109f305eedf1b93b7 Mon Sep 17 00:00:00 2001 From: milahu Date: Sun, 3 Oct 2021 14:53:56 +0200 Subject: [PATCH] use cache_dir by default: ~/.cache/svn2github --- requirements.txt | 1 + svn2github.py | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4c794ea --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +xdg diff --git a/svn2github.py b/svn2github.py index 97ddc0e..a0a74c6 100755 --- a/svn2github.py +++ b/svn2github.py @@ -9,6 +9,8 @@ import shutil import sys import argparse +import xdg +import inspect class Svn2GithubException(Exception): @@ -157,8 +159,20 @@ def sync_github_mirror(github_repo, cache_dir, new_svn_url=None): def main(): - parser = argparse.ArgumentParser(description="Mirror SVN repositories to GitHub") - parser.add_argument("--cache-dir", help="Directory to keep the cached data to avoid re-downloading all SVN and Git history each time. This is optional, but highly recommended") + parser = argparse.ArgumentParser( + description="Mirror SVN repositories to GitHub", + formatter_class=argparse.RawTextHelpFormatter + ) + default_cache_dir = xdg.xdg_cache_home() / "svn2github" + parser.add_argument( + "--cache-dir", + help=inspect.cleandoc(f""" + Directory to keep the cached data, + to avoid re-downloading all SVN and Git history each time. + Default: {default_cache_dir} + """), + default=default_cache_dir + ) subparsers = parser.add_subparsers() subparser_import = subparsers.add_parser("import", help="Import SVN repository to the GitHub repo")