Repository: J-CPelletier/webcomix

Issue:
Custom: Add a -y (yes) option
Looking to use this as a replacement for Dosage, as this allows for custom comics. I'd like to run this daily (or every few days) on a number of comics to pull latest comic. The prompting on Custom Comics (are you sure) is a stumbling block to script it. Can you maybe add a -y to custom, for auto-acknowledging?

Discussion:

Patch:
diff --git a/webcomix/main.py b/webcomix/main.py
index 0053bbb..cba546d 100644
--- a/webcomix/main.py
+++ b/webcomix/main.py
@@ -56,7 +56,12 @@ def download(name, cbz):
     default=False,
     is_flag=True,
     help="Outputs the comic as a cbz file")
-def search(name, start_url, cbz):
+@click.option(
+    "-y",
+    default=False,
+    is_flag=True,
+    help="Assumes 'yes' as an answer to all prompts")
+def search(name, start_url, cbz, y):
     """
     Downloads a webcomic using a general XPath
     """
@@ -67,8 +72,8 @@ def search(name, start_url, cbz):
                                         comic.comic_image_selector)
         print_verification(validation)
         click.echo(
-            "Verify that the links above are correct before proceeding.")
-        if click.confirm("Are you sure you want to proceed?"):
+            "Verify that the links above are correct.")
+        if y or click.confirm("Are you sure you want to proceed?"):
             comic.download(name)
             if cbz:
                 comic.make_cbz(name, name)
@@ -100,7 +105,12 @@ def search(name, start_url, cbz):
     default=False,
     is_flag=True,
     help="Outputs the comic as a cbz file")
-def custom(comic_name, start_url, next_page_xpath, image_xpath, cbz):
+@click.option(
+    "-y",
+    default=False,
+    is_flag=True,
+    help="Assumes 'yes' as an answer to all prompts")
+def custom(comic_name, start_url, next_page_xpath, image_xpath, cbz, y):
     """
     Downloads a user-defined webcomic
     """
@@ -109,8 +119,8 @@ def custom(comic_name, start_url, next_page_xpath, image_xpath, cbz):
                                     comic.next_page_selector,
                                     comic.comic_image_selector)
     print_verification(validation)
-    click.echo("Verify that the links above are correct before proceeding.")
-    if click.confirm("Are you sure you want to proceed?"):
+    click.echo("Verify that the links above are correct.")
+    if y or click.confirm("Are you sure you want to proceed?"):
         comic.download(comic_name)
         if cbz:
             comic.make_cbz(comic_name, comic_name)


Test patch:
diff --git a/webcomix/tests/test_main.py b/webcomix/tests/test_main.py
index ec2c718..c2dcf42 100644
--- a/webcomix/tests/test_main.py
+++ b/webcomix/tests/test_main.py
@@ -100,7 +100,7 @@ def test_custom(monkeypatch):
     assert result.exit_code == 0
     assert result.output.strip() == "\n".join([
         "Verified", "Printed",
-        "Verify that the links above are correct before proceeding.",
+        "Verify that the links above are correct.",
         "Are you sure you want to proceed? [y/N]: yes", "foo"
     ])
 
@@ -119,7 +119,7 @@ def test_custom_make_cbz(monkeypatch):
     assert result.exit_code == 0
     assert result.output.strip() == "\n".join([
         "Verified", "Printed",
-        "Verify that the links above are correct before proceeding.",
+        "Verify that the links above are correct.",
         "Are you sure you want to proceed? [y/N]: y", "foo", ".cbz created"
     ])
 
@@ -139,6 +139,6 @@ def test_search(monkeypatch):
     assert result.exit_code == 0
     assert result.output.strip() == "\n".join([
         "Verified", "Printed",
-        "Verify that the links above are correct before proceeding.",
+        "Verify that the links above are correct.",
         "Are you sure you want to proceed? [y/N]: y", "foo"
     ])