Fixed project versioning. Added some initial argument parsing.
This commit is contained in:
parent
a310c28a52
commit
cde4bffb0d
6 changed files with 79 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -160,3 +160,5 @@ cython_debug/
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
# Version file
|
||||||
|
_version.py
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# SSHare
|
# SSHare
|
||||||
|
|
||||||
Convenience script for uploading files to a server via ssh
|
Upload files to a server via ssh
|
||||||
|
|
||||||
### Hmmm
|
### Hmmm
|
||||||
|
|
||||||
|
|
|
@ -28,3 +28,5 @@ Issues = "https://forge.monodon.me/Gnarwhal/sshare/issues"
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
sshare = "sshare.cli:main"
|
sshare = "sshare.cli:main"
|
||||||
|
|
||||||
|
[tool.setuptools_scm]
|
||||||
|
version_file = "src/sshare/_version.py"
|
||||||
|
|
0
src/sshare/__init__.py
Normal file
0
src/sshare/__init__.py
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from cli import main
|
from cli import main
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -12,16 +12,21 @@
|
||||||
# You should have received a copy of the GNU General Public License along with
|
# You should have received a copy of the GNU General Public License along with
|
||||||
# SSHare. If not, see <https://www.gnu.org/licenses/>.
|
# SSHare. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import argparse
|
||||||
import getpass
|
import getpass
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import pkg_resources
|
||||||
import pyclip
|
import pyclip
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import _version
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
arguments = parse_arguments()
|
||||||
|
|
||||||
config = Config()
|
config = Config()
|
||||||
|
|
||||||
file = _latest("/home/gnarwhal/Pictures/Screenshots")
|
file = _latest("/home/gnarwhal/Pictures/Screenshots")
|
||||||
|
@ -49,6 +54,60 @@ def main():
|
||||||
sys.exit(0)
|
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):
|
def _latest(directory, key=os.path.getmtime):
|
||||||
files = map(lambda file: f"{directory}/{file}", os.listdir(directory))
|
files = map(lambda file: f"{directory}/{file}", os.listdir(directory))
|
||||||
selection = next(files)
|
selection = next(files)
|
||||||
|
|
Loading…
Reference in a new issue