Repository: fniessink/next-action

Issue:
Make the "todo.txt" in the user's home folder the default todo.txt to read

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cae04b8..aba1ba2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
 and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
 
+## [Unreleased]
+
+### Changed
+
+- If no file is specified, *Next-action* tries to read the todo.txt in the user's home folder. Closes #4.
+
 ## [0.3.0] - 2018-05-19
 
 ### Added
diff --git a/README.md b/README.md
index 8e9e88d..4a0f179 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ optional arguments:
   --version             show program's version number and exit
   -f <filename>, --file <filename>
                         filename of todo.txt file to read; can be - to read from standard input; argument can be
-                        repeated to read tasks from multiple todo.txt files (default: ['todo.txt'])
+                        repeated to read tasks from multiple todo.txt files (default: ['~/todo.txt'])
   -n <number>, --number <number>
                         number of next actions to show (default: 1)
   -a, --all             show all next actions (default: False)
@@ -49,7 +49,7 @@ optional context and project arguments; these can be repeated:
   -+<project>           project the next action must not be part of
 ```
 
-Assuming your todo.txt file is in the current folder, running *Next-action* without arguments will show the next action you should do. Given this [todo.txt](todo.txt), calling mom would be the next action:
+Assuming your todo.txt file is your home folder, running *Next-action* without arguments will show the next action you should do. Given this [todo.txt](todo.txt), calling mom would be the next action:
 
 ```console
 $ next-action
diff --git a/next_action/arguments/__init__.py b/next_action/arguments/__init__.py
index 45faa29..2389d2f 100644
--- a/next_action/arguments/__init__.py
+++ b/next_action/arguments/__init__.py
@@ -14,7 +14,7 @@ def parse_arguments() -> Arguments:
     """ Build the argument parser, paerse the command line arguments, and post-process them. """
     # Ensure that the help info is printed using all columns available
     os.environ['COLUMNS'] = str(shutil.get_terminal_size().columns)
-    default_filenames = ["todo.txt"]
+    default_filenames = ["~/todo.txt"]
     parser = build_parser(default_filenames)
     arguments = Arguments(parser, default_filenames)
     namespace, remaining = parser.parse_known_args()
diff --git a/next_action/arguments/arguments.py b/next_action/arguments/arguments.py
index afbe5ac..384e841 100644
--- a/next_action/arguments/arguments.py
+++ b/next_action/arguments/arguments.py
@@ -1,6 +1,7 @@
 """ Argument data class for transfering command line arguments. """
 
 import argparse
+import os.path
 import sys
 from typing import List, Set
 
@@ -28,7 +29,7 @@ class Arguments(object):
             for default_filename in self.__default_filenames:
                 filenames.remove(default_filename)
         # Remove duplicate filenames while maintaining order.
-        self.__filenames = list(dict.fromkeys(filenames))
+        self.__filenames = [os.path.expanduser(filename) for filename in list(dict.fromkeys(filenames))]
 
     def show_all(self, show_all: bool) -> None:
         """ If the user wants to see all next actions, set the number to something big. """
diff --git a/update_readme.py b/update_readme.py
index c86bcb1..96b8da3 100644
--- a/update_readme.py
+++ b/update_readme.py
@@ -18,7 +18,7 @@ def update_readme():
                 in_console_section = False
             elif line.startswith("$ "):
                 print(line)
-                command = line[2:].split(" ")
+                command = line[2:].split(" ") + ["--file", "todo.txt"]
                 command_output = subprocess.run(command, stdout=subprocess.PIPE, universal_newlines=True)
                 print(command_output.stdout.rstrip())
             elif not in_console_section:


Test patch:
diff --git a/tests/unittests/test_arguments.py b/tests/unittests/test_arguments.py
index 7dc6ce6..4c7bbf9 100644
--- a/tests/unittests/test_arguments.py
+++ b/tests/unittests/test_arguments.py
@@ -22,7 +22,7 @@ class NoArgumentTest(unittest.TestCase):
     @patch.object(sys, "argv", ["next-action"])
     def test_filename(self):
         """ Test that the argument parser returns the default filename if the user doesn't pass one. """
-        self.assertEqual(["todo.txt"], parse_arguments().filenames)
+        self.assertEqual([os.path.expanduser("~/todo.txt")], parse_arguments().filenames)
 
 
 class FilenameTest(unittest.TestCase):
diff --git a/tests/unittests/test_cli.py b/tests/unittests/test_cli.py
index 99da454..0cabed3 100644
--- a/tests/unittests/test_cli.py
+++ b/tests/unittests/test_cli.py
@@ -73,7 +73,7 @@ optional arguments:
   --version             show program's version number and exit
   -f <filename>, --file <filename>
                         filename of todo.txt file to read; can be - to read from standard input; argument can be
-                        repeated to read tasks from multiple todo.txt files (default: ['todo.txt'])
+                        repeated to read tasks from multiple todo.txt files (default: ['~/todo.txt'])
   -n <number>, --number <number>
                         number of next actions to show (default: 1)
   -a, --all             show all next actions (default: False)
diff --git a/tests/unittests/test_pick_action.py b/tests/unittests/test_pick_action.py
index 82cbc42..8fec9cc 100644
--- a/tests/unittests/test_pick_action.py
+++ b/tests/unittests/test_pick_action.py
@@ -145,4 +145,4 @@ class IgnoredTasksTest(unittest.TestCase):
         completed_task1 = todotxt.Task("x Completed")
         completed_task2 = todotxt.Task("x Completed too")
         future_task = todotxt.Task("(A) 9999-01-01 Start preparing for five-digit years")
-        self.assertEqual([], pick_action.next_actions([completed_task1, completed_task2, future_task]))
\ No newline at end of file
+        self.assertEqual([], pick_action.next_actions([completed_task1, completed_task2, future_task]))