Skip to content

Commit 151e25a

Browse files
✨ [+feature] Added mirror functionality (#1)
2 parents 004658c + 13fc64d commit 151e25a

29 files changed

+6340
-172
lines changed

.github/workflows/standard.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ jobs:
183183
with:
184184
operating_system: ${{ matrix.os }}
185185
python_version: ${{ matrix.python_version }}
186-
validation_command: FileBackup Version
186+
validation_command: FileBackup version
187187

188188

189189
# ----------------------------------------------------------------------
@@ -239,4 +239,3 @@ jobs:
239239
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
240240

241241
MINISIGN_PRIVATE_KEY: ${{ secrets.MINISIGN_PRIVATE_KEY }}
242-

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ Deactivate*.sh
1212
build/**
1313
dist/**
1414
src/FileBackup.egg-info/**
15+
16+
minisign_key.pri
17+
minisign_key.pub

.python_project_bootstrapper_manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.github/release_sources.yaml: c2241d25423ec6e22afa41c6caed30162438af803e6de74ee466479ca6cd8246
88
.github/workflows/codeql.yml: 5e6e94a06f17ebbd8d3042467327837bb2076c29a1414b794800a3c1b09cca7d
99
.github/workflows/standard.yaml: 9b11066818a63fa28c19fae3b85f6737b8b805e40fd35635477af34ed40b93ea
10-
.gitignore: 37e0bff616592f003f1c993025a21e7f3a92c8f8f3bba8ffee8a8f9c2ce54365
10+
.gitignore: 4431dbdb4c35765df68c0084dd823a53749423267d3174b031f285df71049a87
1111
.python_project_bootstrapper_config.yml: 80ac560edbf136640da3cd66f0d0ea629ef052d095c6ebb26743a01c6559e0d5
1212
ActivateEpilog.py: 102bb407fb3efcdbb697c4c5ea0d98236d43490ff9297bfa00b37ffaed66501d
1313
Bootstrap.cmd: 48a673262f121c847d924d9b4b1db2a7ee01ef46d0aca8912d0c90f1f1d464c1

Build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def list_commands(self, *args, **kwargs): # pylint: disable=unused-argument
5454
this_dir,
5555
package_dir.name,
5656
app,
57-
default_min_coverage=90.0,
57+
default_min_coverage=75.0,
5858
)
5959

6060
UpdateVersion = RepoBuildTools.UpdateVersionFuncFactory(

pyproject.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ classifiers = [
4343
]
4444

4545
dependencies = [
46-
# TODO
46+
"dbrownell_Common",
47+
"paramiko ~= 3.4",
4748
"typer ~= 0.9"
4849
]
4950

@@ -70,7 +71,7 @@ Documentation = "https://github.com/davidbrownell/FileBackup"
7071
Repository = "https://github.com/davidbrownell/FileBackup"
7172

7273
[project.scripts]
73-
FileBackup = "FileBackup:EntryPoint.app"
74+
FileBackup = "FileBackup.CommandLine:EntryPoint.app"
7475

7576
# ----------------------------------------------------------------------
7677
# |
@@ -80,6 +81,16 @@ FileBackup = "FileBackup:EntryPoint.app"
8081
[tool.black]
8182
line-length = 100
8283

84+
# ----------------------------------------------------------------------
85+
# |
86+
# | coverage
87+
# |
88+
# ----------------------------------------------------------------------
89+
[tool.coverage.run]
90+
omit = [
91+
"*/Impl/*",
92+
]
93+
8394
# ----------------------------------------------------------------------
8495
# |
8596
# | pylint

src/BuildBinary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def _GetVersionAndDocstring() -> tuple[str, str]:
3333
# ----------------------------------------------------------------------
3434
@cache
3535
def _GetEntryPoint() -> Path:
36-
return PathEx.EnsureFile(Path(__file__).parent / _GetName() / "EntryPoint.py")
36+
return PathEx.EnsureFile(Path(__file__).parent / _GetName() / "CommandLine" / "EntryPoint.py")
3737

3838

3939
# ----------------------------------------------------------------------
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# ----------------------------------------------------------------------
2+
# |
3+
# | CommandLineArguments.py
4+
# |
5+
# | David Brownell <db@DavidBrownell.com>
6+
# | 2024-06-12 13:20:05
7+
# |
8+
# ----------------------------------------------------------------------
9+
# |
10+
# | Copyright David Brownell 2024
11+
# | Distributed under the MIT License.
12+
# |
13+
# ----------------------------------------------------------------------
14+
15+
import re
16+
17+
from typing import Pattern
18+
19+
import typer
20+
21+
22+
# ----------------------------------------------------------------------
23+
def ToRegex(
24+
values: list[str],
25+
) -> list[Pattern]:
26+
expressions: list[Pattern] = []
27+
28+
for value in values:
29+
try:
30+
expressions.append(re.compile("^{}$".format(value)))
31+
except re.error as ex:
32+
raise typer.BadParameter(
33+
"The regular expression '{}' is not valid ({}).".format(value, ex)
34+
)
35+
36+
return expressions
37+
38+
39+
# ----------------------------------------------------------------------
40+
input_filename_or_dirs_argument = typer.Argument(
41+
..., exists=True, resolve_path=True, help="Input filename or directory."
42+
)
43+
44+
ssd_option = typer.Option(
45+
"--ssd",
46+
help="Processes tasks in parallel to leverage the capabilities of solid-state-drives.",
47+
)
48+
ssd_option_default = False
49+
50+
quiet_option = typer.Option("--quiet", help="Reduce the amount of information displayed.")
51+
quiet_option_default = False
52+
53+
force_option = typer.Option(
54+
"--force",
55+
help="Ignore previous backup information and overwrite all data in the destination data store.",
56+
)
57+
force_option_default = False
58+
59+
verbose_option = typer.Option("--verbose", help="Write verbose information to the terminal.")
60+
verbose_option_default = False
61+
62+
debug_option = typer.Option("--debug", help="Write debug information to the terminal.")
63+
debug_option_default = False
64+
65+
file_include_option = typer.Option(
66+
"--file-include",
67+
callback=ToRegex,
68+
help="Regular expression (based on a posix path) used to include files and/or directories when preserving content.",
69+
)
70+
file_include_option_default: list[str] = []
71+
72+
file_exclude_option = typer.Option(
73+
"--file-exclude",
74+
callback=ToRegex,
75+
help="Regular expression (based on a posix path) used to exclude files and/or directories when preserving content.",
76+
)
77+
file_exclude_option_default: list[str] = []
Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313
from typer.core import TyperGroup # type: ignore [import-untyped]
1414

15-
from FileBackup import Math, __version__
15+
from FileBackup import __version__
16+
from FileBackup.CommandLine import MirrorEntryPoint
1617

1718

1819
# ----------------------------------------------------------------------
@@ -33,56 +34,12 @@ def list_commands(self, *args, **kwargs): # pylint: disable=unused-argument
3334
)
3435

3536

36-
# ----------------------------------------------------------------------
37-
@app.command("Add")
38-
def Add(
39-
x: int,
40-
y: int,
41-
) -> None:
42-
"""Adds 2 values."""
43-
44-
sys.stdout.write(str(Math.Add(x, y)))
45-
46-
47-
# ----------------------------------------------------------------------
48-
@app.command("Sub")
49-
def Sub(
50-
x: int,
51-
y: int,
52-
) -> None:
53-
"""Subtracts 2 values."""
54-
55-
sys.stdout.write(str(Math.Sub(x, y)))
56-
57-
58-
# ----------------------------------------------------------------------
59-
@app.command("Mult")
60-
def Mult(
61-
x: int,
62-
y: int,
63-
) -> None:
64-
"""Multiplies 2 values."""
65-
66-
sys.stdout.write(str(Math.Mult(x, y)))
67-
68-
69-
# ----------------------------------------------------------------------
70-
@app.command("Div")
71-
def Div(
72-
x: int,
73-
y: int,
74-
) -> None:
75-
"""Divides 1 value by another."""
76-
77-
sys.stdout.write(str(Math.Div(x, y)))
37+
app.add_typer(MirrorEntryPoint.app, name="mirror", help=MirrorEntryPoint.__doc__)
7838

7939

80-
# ----------------------------------------------------------------------
81-
@app.command("Version")
82-
def Version() -> None:
83-
"""Prints the version of the package."""
84-
85-
sys.stdout.write(__version__)
40+
@app.command("version", no_args_is_help=False)
41+
def Version():
42+
sys.stdout.write(f"FileBackup v{__version__}\n")
8643

8744

8845
# ----------------------------------------------------------------------

0 commit comments

Comments
 (0)