diff --git a/.gitignore b/.gitignore index 5d381cc..678f87e 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,5 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +# Version file +_version.py diff --git a/README.md b/README.md index 7cc9123..3a25e17 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SSHare -Convenience script for uploading files to a server via ssh +Upload files to a server via ssh ### Hmmm diff --git a/pyproject.toml b/pyproject.toml index a7af96b..ab9befc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,3 +28,5 @@ Issues = "https://forge.monodon.me/Gnarwhal/sshare/issues" [project.scripts] sshare = "sshare.cli:main" +[tool.setuptools_scm] +version_file = "src/sshare/_version.py" diff --git a/src/sshare/__init__.py b/src/sshare/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/sshare/__main__.py b/src/sshare/__main__.py index d92dc90..6545e2b 100644 --- a/src/sshare/__main__.py +++ b/src/sshare/__main__.py @@ -1,3 +1,17 @@ +# This file is part of SSHare. +# +# SSHare 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. +# +# SSHare 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 +# SSHare. If not, see . + from cli import main main() diff --git a/src/sshare/cli.py b/src/sshare/cli.py index bc2492d..f96f8b5 100644 --- a/src/sshare/cli.py +++ b/src/sshare/cli.py @@ -10,18 +10,23 @@ # more details. # # You should have received a copy of the GNU General Public License along with -# SSHare. If not, see . +# SSHare. If not, see . +import argparse import getpass import importlib.util import os import os.path +import pkg_resources import pyclip import time import subprocess import sys +import _version def main(): + arguments = parse_arguments() + config = Config() file = _latest("/home/gnarwhal/Pictures/Screenshots") @@ -49,6 +54,60 @@ def main(): sys.exit(0) +def parse_arguments(): + parser = argparse.ArgumentParser( + prog = "SSHare", + description = "Upload files to a server via ssh", + formatter_class = argparse.RawDescriptionHelpFormatter, + epilog = +""" +Configuration Files: + + Configuration files will be looked for in + '$XDG_CONFIG_DIR/sshare/'. If XDG_DATA_DIR is not set, + SSHare will fallback to '$HOME/.config/sshare/'. + + If it exists, `default.py' will be considered as config[0]. + Otherwise, all other configuration files will be ordered + alphabetically. +""" + ) + + parser.add_argument( + "-v", + "--version", + action="version", + version=f"%(prog)s version {_version.version}", + ) + parser.add_argument( + "-l", + "--list", + action="store_const", + help="List available configuration files", + ) + parser.add_argument( + "-c", + "--config", + help="Use the config at location CONFIG", + ) + parser.add_argument( + "-n", + "--number", + type=int, + default=0, + help="Use config number n (Default: 0)", + ) + parser.add_argument( + "-i", + "--interactive", + action="store_const", + help="Run interactively", + ) + arguments = parser.parse_args() + + return arguments + + def _latest(directory, key=os.path.getmtime): files = map(lambda file: f"{directory}/{file}", os.listdir(directory)) selection = next(files)