Repository: rachmadaniHaryono/we-get

Issue:
Default -t to all
I was wondering if it would make sense to default the target parameter to all if it isn't specified.
Currently no search will take place if the parameter is omitted.

That way you get the most results by default and only narrow them down **if** you want them to be.

Comments:

Patch:
diff --git a/README.rst b/README.rst
index 3f7125f..050d69a 100644
--- a/README.rst
+++ b/README.rst
@@ -66,13 +66,13 @@ Options
 ===================== =====================================================
 -s --search=<text>    Search for a torrent.                                
 -l --list             List top torrents from modules.                      
--t --target=<target>  Select module to use or 'all'.                       
+-t --target=<target>  Select module to use or 'all' [default: all].                       
 -L --links            Output results as links.                             
 -J --json             Output results in JSON format.                       
 -G --get-list         List targets (supported web-sites).                  
 -f --filter=<str>     Match text or regular expression in the torrent name.
 -n --results=<n>      Number of results to retrieve.                       
--S --sort-type=<type> Sort torrents by name/seeds (default: seeds).        
+-S --sort-type=<type> Sort torrents by name/seeds [default: seeds].        
 ===================== =====================================================
 
 Video options
diff --git a/changelog.rst b/changelog.rst
index 8af0274..9f65658 100644
--- a/changelog.rst
+++ b/changelog.rst
@@ -14,6 +14,12 @@ New
 - user status for pirate bay
 - argv for arguments
 
+Changes
+~~~~~~~
+
+- target parameter default to all
+
+
 1.1.0 - 2018-07-08
 ------------------
 
diff --git a/we_get/core/we_get.py b/we_get/core/we_get.py
index 4dddbc4..a4da5a0 100644
--- a/we_get/core/we_get.py
+++ b/we_get/core/we_get.py
@@ -28,13 +28,13 @@ __doc__ = """Usage: we-get [options]...
 Options:
   -s --search=<text>    Search for a torrent.
   -l --list             List top torrents from modules.
-  -t --target=<target>  Select module to use or \'all\'.
+  -t --target=<target>  Select module to use or 'all' [default: all].
   -L --links            Output results as links.
   -J --json             Output results in JSON format.
   -G --get-list         List targets (supported web-sites).
   -f --filter=<str>     Match text or regular expression in the torrent name.
   -n --results=<n>      Number of results to retrieve.
-  -S --sort-type=<type> Sort torrents by name/seeds (default: seeds).
+  -S --sort-type=<type> Sort torrents by name/seeds [default: seeds].
 
 Video options:
   -q --quality=<q>      Try to match quality for the torrent (720p,1080p, ...).


Test patch:
diff --git a/tests/test_core_we_get.py b/tests/test_core_we_get.py
new file mode 100644
index 0000000..5d30afc
--- /dev/null
+++ b/tests/test_core_we_get.py
@@ -0,0 +1,61 @@
+import pytest
+from docopt import docopt, DocoptExit
+
+from we_get.core.we_get import WG
+from we_get.core import we_get
+
+
+@pytest.mark.parametrize(
+    'argv, exp_res',
+    [
+        [None, {'arguments': None, 'parguments': {}, 'we_get_run': 0}],
+        [['--search', 'ubuntu'],  {
+            'arguments': {
+                '--filter': [],
+                '--genre': [],
+                '--get-list': 0,
+                '--help': 0,
+                '--json': 0,
+                '--links': 0,
+                '--list': 0,
+                '--quality': [],
+                '--results': [],
+                '--search': ['ubuntu'],
+                '--sort-type': [],
+                '--target': ['all'],
+                '--version': 0
+            },
+            'parguments': {
+                '--search': ['ubuntu'], '--target': ['all']}, 'we_get_run': 1
+        }],
+    ]
+)
+def test_parse_arguments(argv, exp_res):
+    wg = WG()
+    if argv is None:
+        with pytest.raises(DocoptExit):
+            wg.parse_arguments()
+        assert vars(wg) == exp_res
+        with pytest.raises(DocoptExit):
+            wg.parse_arguments(argv)
+        assert vars(wg) == exp_res
+    else:
+        wg.parse_arguments(argv)
+        assert vars(wg) == exp_res
+
+
+@pytest.mark.parametrize(
+    'argv, exp_res',
+    [
+        [
+            [],
+            {
+                '--filter': [], '--genre': [], '--get-list': 0, '--help': 0, '--json': 0,
+                '--links': 0, '--list': 0, '--quality': [], '--results': [], '--search': [],
+                '--sort-type': [], '--target': ['all'], '--version': 0}
+        ],
+    ],
+)
+def test_we_get_docopt(argv, exp_res):
+    res = docopt(we_get.__doc__, argv=argv)
+    assert exp_res == res
diff --git a/tests/test_doc.py b/tests/test_doc.py
new file mode 100644
index 0000000..aa689ed
--- /dev/null
+++ b/tests/test_doc.py
@@ -0,0 +1,27 @@
+from datetime import datetime
+
+
+def test_arg_option_doc():
+    with open('README.rst') as f:
+        content = f.read()
+    option_parts = content.split('Options\n-------')[1].split('Video options\n')[0].strip()
+    option_parts = option_parts.splitlines()[1:-1]
+    option_parts = [x.split(' ', 2) for x in option_parts]
+    for idx, x in enumerate(option_parts):
+        option_parts[idx][2] = x[2].strip()
+    with open('we_get/core/we_get.py') as f:
+        m_content = f.read()
+    m_option_parts = m_content.split('Options:')[1].split('Video options')[0].strip().splitlines()
+    m_option_parts = [x.strip().split(' ', 2) for x in m_option_parts]
+    for idx, x in enumerate(m_option_parts):
+        m_option_parts[idx][2] = x[2].strip()
+    assert option_parts == m_option_parts
+
+
+def test_year():
+    current_year = datetime.now().year
+    with open('we_get/core/we_get.py') as f:
+        m_content = f.read()
+    m_content.splitlines()[1]
+    year = m_content.split('Copyright (c) 2016-')[1].split(' ')[0]
+    assert year == str(current_year)