From 9dbb07d0c785b75df3efed56e82a7735983f6e81 Mon Sep 17 00:00:00 2001
From: Einar Forselv <eforselv@gmail.com>
Date: Tue, 3 Dec 2019 05:06:28 +0100
Subject: [PATCH] Shorten all restic commands

---
 restic_volume_backup/restic.py | 50 ++++++++++------------------------
 1 file changed, 14 insertions(+), 36 deletions(-)

diff --git a/restic_volume_backup/restic.py b/restic_volume_backup/restic.py
index 398f591..7d150d3 100644
--- a/restic_volume_backup/restic.py
+++ b/restic_volume_backup/restic.py
@@ -14,27 +14,17 @@ def init_repo(repository: str):
     Attempt to initialize the repository.
     Doing this after the repository is initialized
     """
-    return commands.run([
-        "restic",
-        "--cache-dir",
-        "/restic_cache",
-        "-r",
-        repository,
+    return commands.run(restic(repository, [
         "init",
-    ])
+    ]))
 
 
 def backup_files(repository: str, source='/backup'):
-    return commands.run([
-        "restic",
-        "--cache-dir",
-        "/restic_cache",
-        "-r",
-        repository,
+    return commands.run(restic(repository, [
         "--verbose",
         "backup",
         source,
-    ])
+    ]))
 
 
 def backup_from_stdin(repository: str, filename: str, source_command: List[str]):
@@ -42,14 +32,12 @@ def backup_from_stdin(repository: str, filename: str, source_command: List[str])
     Backs up from stdin running the source_command passed in.
     It will appear in restic with the filename (including path) passed in.
     """
-    dest_command = restic(repository,
-        [
-            'backup',
-            '--stdin',
-            '--stdin-filename',
-            filename,
-        ],
-    )
+    dest_command = restic(repository, [
+        'backup',
+        '--stdin',
+        '--stdin-filename',
+        filename,
+    ])
 
     # pipe source command into dest command
     source_process = Popen(source_command, stdout=PIPE)
@@ -58,25 +46,15 @@ def backup_from_stdin(repository: str, filename: str, source_command: List[str])
 
 
 def snapshots(repository: str):
-    return commands.run([
-        "restic",
-        "--cache-dir",
-        "/restic_cache",
-        "-r",
-        repository,
+    return commands.run(restic(repository, [
         "snapshots",
-    ])
+    ]))
 
 
 def check(repository: str):
-    return commands.run([
-        "restic",
-        "--cache-dir",
-        "/restic_cache",
-        "-r",
-        repository,
+    return commands.run(restic(repository, [
         "check",
-    ])
+    ]))
 
 
 def restic(repository: str, args: List[str]):