Browse Source

BREAKING CHANGE: Moving store_path to only the store action

pull/8/head
Ryan Reed 2 years ago
parent
commit
494cfaa7bf
3 changed files with 12 additions and 15 deletions
  1. +1
    -1
      README.md
  2. +9
    -10
      src/transpose/console.py
  3. +2
    -4
      src/transpose/transpose.py

+ 1
- 1
README.md View File

@ -49,7 +49,7 @@ transpose restore ~/.local/share/transpose/zsh # Remove symlink, move ~/.local/
transpose apply ~/.local/share/transpose/zsh # Recreate symlink in cache location transpose apply ~/.local/share/transpose/zsh # Recreate symlink in cache location
transpose create ~/.config/zsh ~/.local/share/transpose/zsh # Recreate cache file transpose create ~/.config/zsh ~/.local/share/transpose/zsh # Recreate cache file
transpose -s /mnt/backups store ~/.config/zsh zsh_config # Move ~/.config/zsh -> /mnt/backups/zsh_config, create symlink, create cache
transpose store ~/.config/zsh zsh_config -s /mnt/backups # Move ~/.config/zsh -> /mnt/backups/zsh_config, create symlink, create cache
transpose --cache-filename .mycache.json restore /mnt/backups/zsh_config # Use /mnt/backup/.zsh_config.json for restoring a stored directory transpose --cache-filename .mycache.json restore /mnt/backups/zsh_config # Use /mnt/backup/.zsh_config.json for restoring a stored directory
``` ```


+ 9
- 10
src/transpose/console.py View File

@ -9,7 +9,6 @@ def entry_point() -> None:
t = Transpose( t = Transpose(
target_path=args.target_path, target_path=args.target_path,
store_path=args.store_path,
cache_filename=args.cache_filename, cache_filename=args.cache_filename,
) )
@ -20,7 +19,7 @@ def entry_point() -> None:
elif args.action == "restore": elif args.action == "restore":
t.restore() t.restore()
elif args.action == "store": elif args.action == "store":
t.store(name=args.name)
t.store(store_path=args.store_path, name=args.name)
def parse_arguments(args=None): def parse_arguments(args=None):
@ -43,14 +42,6 @@ def parse_arguments(args=None):
""", """,
) )
parser.add_argument("--version", action="version", version=f"Transpose {version}") parser.add_argument("--version", action="version", version=f"Transpose {version}")
parser.add_argument(
"-s",
"--store-path",
dest="store_path",
nargs="?",
default=store_path,
help="The path to where the targets should be stored (default: %(default)s)",
)
subparsers = parser.add_subparsers( subparsers = parser.add_subparsers(
help="Transpose Action", dest="action", required=True help="Transpose Action", dest="action", required=True
@ -105,6 +96,14 @@ def parse_arguments(args=None):
default=None, default=None,
help="The name of the directory that will be created in the store path (default: target_path)", help="The name of the directory that will be created in the store path (default: target_path)",
) )
store_parser.add_argument(
"-s",
"--store-path",
dest="store_path",
nargs="?",
default=store_path,
help="The path to where the targets should be stored (default: %(default)s)",
)
return parser.parse_args(args) return parser.parse_args(args)


+ 2
- 4
src/transpose/transpose.py View File

@ -8,11 +8,9 @@ class Transpose:
def __init__( def __init__(
self, self,
target_path: str, target_path: str,
store_path: str,
cache_filename: str = None, cache_filename: str = None,
) -> None: ) -> None:
self.target_path = pathlib.Path(target_path) self.target_path = pathlib.Path(target_path)
self.store_path = pathlib.Path(store_path)
if not cache_filename: if not cache_filename:
cache_filename = ".transpose.json" cache_filename = ".transpose.json"
@ -86,14 +84,14 @@ class Transpose:
new_cache_path = pathlib.Path(original_path).joinpath(self.cache_filename) new_cache_path = pathlib.Path(original_path).joinpath(self.cache_filename)
remove(new_cache_path) remove(new_cache_path)
def store(self, name: str = None) -> None:
def store(self, store_path: str, name: str = None) -> None:
""" """
Moves a directory to a central location and creates a symlink to the old path. Moves a directory to a central location and creates a symlink to the old path.
""" """
if name is None: if name is None:
name = self.target_path.name name = self.target_path.name
new_location = pathlib.Path(self.store_path).joinpath(name)
new_location = pathlib.Path(store_path).joinpath(name)
if not check_path(path=self.target_path): if not check_path(path=self.target_path):
raise TransposeError( raise TransposeError(


Loading…
Cancel
Save