瀏覽代碼

feat: Enable --depth flag (still does nothing)

Cristian 5 年之前
父節點
當前提交
8b22a2a7dd
共有 2 個文件被更改,包括 14 次插入6 次删除
  1. 7 6
      archivebox/cli/archivebox_add.py
  2. 7 0
      tests/test_args.py

+ 7 - 6
archivebox/cli/archivebox_add.py

@@ -45,6 +45,13 @@ def main(args: Optional[List[str]]=None, stdin: Optional[IO]=None, pwd: Optional
             '    ~/Desktop/sites_list.csv\n'
         )
     )
+    parser.add_argument(
+        "--depth",
+        action="store",
+        default=0,
+        type=int,
+        help="Recursively archive all linked pages up to this many hops away"
+    )
     command = parser.parse_args(args or ())
     import_str = accept_stdin(stdin)
     add(
@@ -63,12 +70,6 @@ if __name__ == '__main__':
 # TODO: Implement these
 #
 # parser.add_argument(
-#     '--depth', #'-d',
-#     type=int,
-#     help='Recursively archive all linked pages up to this many hops away',
-#     default=0,
-# )
-# parser.add_argument(
 #     '--mirror', #'-m',
 #     action='store_true',
 #     help='Archive an entire site (finding all linked pages below it on the same domain)',

+ 7 - 0
tests/test_args.py

@@ -0,0 +1,7 @@
+import subprocess
+
+from .fixtures import *
+
+def test_depth_flag_is_accepted(tmp_path, process):
+    arg_process = subprocess.run(["archivebox", "add", "https://example.com", "--depth=0"], capture_output=True)
+    assert 'unrecognized arguments: --depth' not in arg_process.stderr.decode('utf-8')