Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove time-travel feature. #326

Merged
merged 4 commits into from Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitlab-ci.yml
Expand Up @@ -41,7 +41,6 @@ security:
artifacts:
paths:
- build/bandit.html
- build/owasp-dependency-check-report

quality:
stage: test
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Expand Up @@ -5,8 +5,16 @@ 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).

## [1.10.0] - UNRELEASED

### Removed

- Removed time travel feature as it's not very useful.

## [1.9.0] - 2018-10-20

### Added

- Show 😴 emoji when there's nothing to do. Closes #256.

## [1.8.1] - 2018-09-07
Expand Down
76 changes: 33 additions & 43 deletions README.md
Expand Up @@ -24,7 +24,6 @@ Don't know what *Todo.txt* is? See <https://github.com/todotxt/todo.txt> for the
- [Showing more than one next action](#showing-more-than-one-next-action)
- [Task dependencies](#task-dependencies)
- [Styling the output](#styling-the-output)
- [Time travel](#time-travel)
- [Configuring *Next-action*](#configuring-next-action)
- [Option details](#option-details)
- [Recent changes](#recent-changes)
Expand Down Expand Up @@ -69,8 +68,8 @@ arguments, shows the possible arguments.

```console
$ next-action --help
Usage: next-action [-h] [-V] [-c [<config.cfg>] | -w] [-f <todo.txt> ...] [-t [<date>]] [-b] [-r <ref>] [-s
[<style>]] [-a | -n <number>] [-d [<due date>] | -o] [-p [<priority>]] [--] [<context|project> ...]
Usage: next-action [-h] [-V] [-c [<config.cfg>] | -w] [-f <todo.txt> ...] [-b] [-r <ref>] [-s [<style>]] [-a |
-n <number>] [-d [<due date>] | -o] [-p [<priority>]] [--] [<context|project> ...]

Show the next action in your todo.txt. The next action is selected from the tasks in the todo.txt file based
on task properties such as priority, due date, and creation date. Limit the tasks from which the next action
Expand All @@ -91,9 +90,6 @@ Input options:
-f <todo.txt>, --file <todo.txt>
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)
-t [<date>], --time-travel [<date>]
time travel to the given date and show the next action(s) at that date (default:
tomorrow)

Output options:
-b, --blocked show the tasks blocked by the next action, if any (default: False)
Expand Down Expand Up @@ -336,16 +332,6 @@ section below on how to configure *Next-action*.

Not passing an argument to `--style` cancels the style that is configured in the configuration file, if any.

### Time travel

If you want to know what the next action would be if it were tomorrow, Monday, or a specific date, you can tell
*Next-action* to pretend it's that day.

```console
$ next-action --time-travel 3000
(A) Start preparing for emigration to Mars t:3000-01-01 due:3500-12-31
```

### Configuring *Next-action*

In addition to specifying options on the command-line, you can also configure options in a configuration file. The
Expand Down Expand Up @@ -515,8 +501,8 @@ will interpret the positional argument as the argument to the option and complai

```console
$ next-action --due @home
Usage: next-action [-h] [-V] [-c [<config.cfg>] | -w] [-f <todo.txt> ...] [-t [<date>]] [-b] [-r <ref>] [-s
[<style>]] [-a | -n <number>] [-d [<due date>] | -o] [-p [<priority>]] [--] [<context|project> ...]
Usage: next-action [-h] [-V] [-c [<config.cfg>] | -w] [-f <todo.txt> ...] [-b] [-r <ref>] [-s [<style>]] [-a |
-n <number>] [-d [<due date>] | -o] [-p [<priority>]] [--] [<context|project> ...]
next-action: error: argument -d/--due: invalid date: @home
```

Expand Down Expand Up @@ -557,20 +543,23 @@ To run the unit tests and check their code coverage:

```console
$ docker-compose --no-ansi up unittest
Starting next-action_unittest_1 ...
Starting next-action_unittest_1 ... done
Creating network "next-action_default" with the default driver
Creating next-action_unittest_1 ...
Creating next-action_unittest_1 ... done
Attaching to next-action_unittest_1
unittest_1 | ----------------------------------------------------------------------
unittest_1 | Ran 250 tests in 1.869s
unittest_1 | Ran 245 tests in 2.134s
unittest_1 |
unittest_1 | OK
unittest_1 | Name Stmts Miss Branch BrPart Cover
unittest_1 | -----------------------------------------
unittest_1 | -----------------------------------------
unittest_1 | TOTAL 1602 0 226 0 100%
unittest_1 | Name Stmts Miss Branch BrPart Cover
unittest_1 | -------------------------------------------------------------------
unittest_1 | next_action/arguments/parser.py 168 1 64 1 99%
unittest_1 | next_action/output/__init__.py 44 1 24 1 97%
unittest_1 | -------------------------------------------------------------------
unittest_1 | TOTAL 1584 2 222 2 99%
unittest_1 |
unittest_1 | 29 files skipped due to complete coverage.
next-action_unittest_1 exited with code 0
unittest_1 | 27 files skipped due to complete coverage.
next-action_unittest_1 exited with code 2
```

The HTML coverage report is written to `build/unittest-coverage/`.
Expand All @@ -581,20 +570,21 @@ To run the feature tests and measure their code coverage:

```console
$ docker-compose --no-ansi up behave
Starting next-action_behave_1 ...
Starting next-action_behave_1 ... done
Creating next-action_behave_1 ...
Creating next-action_behave_1 ... done
Attaching to next-action_behave_1
behave_1 | 16 features passed, 0 failed, 0 skipped
behave_1 | 108 scenarios passed, 0 failed, 0 skipped
behave_1 | 362 steps passed, 0 failed, 0 skipped, 0 undefined
behave_1 | Took 1m32.291s
behave_1 | Name Stmts Miss Branch BrPart Cover
behave_1 | -----------------------------------------
behave_1 | -----------------------------------------
behave_1 | TOTAL 480 0 206 0 100%
behave_1 | 15 features passed, 0 failed, 0 skipped
behave_1 | 105 scenarios passed, 0 failed, 0 skipped
behave_1 | 346 steps passed, 0 failed, 0 skipped, 0 undefined
behave_1 | Took 1m36.711s
behave_1 | Name Stmts Miss Branch BrPart Cover
behave_1 | -------------------------------------------------------------------
behave_1 | next_action/arguments/parser.py 168 1 64 1 99%
behave_1 | -------------------------------------------------------------------
behave_1 | TOTAL 475 1 204 1 99%
behave_1 |
behave_1 | 12 files skipped due to complete coverage.
next-action_behave_1 exited with code 0
behave_1 | 11 files skipped due to complete coverage.
next-action_behave_1 exited with code 2
```

The HTML coverage report is written to `build/feature-coverage/`.
Expand All @@ -610,13 +600,13 @@ To run the quality checks:

```console
$ docker-compose --no-ansi up quality
Starting next-action_quality_1 ...
Starting next-action_quality_1 ... done
Creating next-action_quality_1 ...
Creating next-action_quality_1 ... done
Attaching to next-action_quality_1
quality_1 | Generated HTML report (via XSLT): /Users/fniessink/workspace/next-action/build/mypy/index.html
quality_1 |
quality_1 | --------------------------------------------------------------------
quality_1 | Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
quality_1 | ------------------------------------
quality_1 | Your code has been rated at 10.00/10
quality_1 |
quality_1 | ------------------------------
quality_1 | Checking .
Expand Down
21 changes: 4 additions & 17 deletions docs/README.in.md
Expand Up @@ -48,8 +48,8 @@ arguments, shows the possible arguments.

```console
$ next-action --help
Usage: next-action [-h] [-V] [-c [<config.cfg>] | -w] [-f <todo.txt> ...] [-t [<date>]] [-b] [-r <ref>] [-s
[<style>]] [-a | -n <number>] [-d [<due date>] | -o] [-p [<priority>]] [--] [<context|project> ...]
Usage: next-action [-h] [-V] [-c [<config.cfg>] | -w] [-f <todo.txt> ...] [-b] [-r <ref>] [-s [<style>]] [-a |
-n <number>] [-d [<due date>] | -o] [-p [<priority>]] [--] [<context|project> ...]

Show the next action in your todo.txt. The next action is selected from the tasks in the todo.txt file based
on task properties such as priority, due date, and creation date. Limit the tasks from which the next action
Expand All @@ -70,9 +70,6 @@ Input options:
-f <todo.txt>, --file <todo.txt>
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)
-t [<date>], --time-travel [<date>]
time travel to the given date and show the next action(s) at that date (default:
tomorrow)

Output options:
-b, --blocked show the tasks blocked by the next action, if any (default: False)
Expand Down Expand Up @@ -315,16 +312,6 @@ section below on how to configure *Next-action*.

Not passing an argument to `--style` cancels the style that is configured in the configuration file, if any.

### Time travel

If you want to know what the next action would be if it were tomorrow, Monday, or a specific date, you can tell
*Next-action* to pretend it's that day.

```console
$ next-action --time-travel 3000
(A) Start preparing for emigration to Mars t:3000-01-01 due:3500-12-31
```

### Configuring *Next-action*

In addition to specifying options on the command-line, you can also configure options in a configuration file. The
Expand Down Expand Up @@ -494,8 +481,8 @@ will interpret the positional argument as the argument to the option and complai

```console
$ next-action --due @home
Usage: next-action [-h] [-V] [-c [<config.cfg>] | -w] [-f <todo.txt> ...] [-t [<date>]] [-b] [-r <ref>] [-s
[<style>]] [-a | -n <number>] [-d [<due date>] | -o] [-p [<priority>]] [--] [<context|project> ...]
Usage: next-action [-h] [-V] [-c [<config.cfg>] | -w] [-f <todo.txt> ...] [-b] [-r <ref>] [-s [<style>]] [-a |
-n <number>] [-d [<due date>] | -o] [-p [<priority>]] [--] [<context|project> ...]
next-action: error: argument -d/--due: invalid date: @home
```

Expand Down
2 changes: 1 addition & 1 deletion next_action/__init__.py
Expand Up @@ -7,7 +7,7 @@


__title__ = "next-action"
__version__ = "1.9.0"
__version__ = "1.10.0"


def next_action() -> None:
Expand Down
12 changes: 3 additions & 9 deletions next_action/arguments/parser.py
Expand Up @@ -15,7 +15,7 @@

ARGUMENTS = ("@", "+", "-@", "-+", "-a", "--all", "-b", "--blocked", "-c", "--config-file", "-d", "--due",
"-f", "--file", "-h", "--help", "-n", "--number", "-o", "--overdue", "-p", "--priority", "-r",
"--reference", "-s", "--style", "-t", "--time-travel", "-V", "--version")
"--reference", "-s", "--style", "-V", "--version")
REFERENCE_CHOICES = ("always", "never", "multiple")


Expand All @@ -26,8 +26,8 @@ def __init__(self, version: str = "?") -> None:
"""Initialize the parser."""
super().__init__(
usage=textwrap.fill("next-action [-h] [-V] [-c [<config.cfg>] | -w] [-f <todo.txt> ...] "
"[-t [<date>]] [-b] [-r <ref>] [-s [<style>]] [-a | -n <number>] "
"[-d [<due date>] | -o] [-p [<priority>]] [--] [<context|project> ...]",
"[-b] [-r <ref>] [-s [<style>]] [-a | -n <number>] [-d [<due date>] | -o] "
"[-p [<priority>]] [--] [<context|project> ...]",
width=shutil.get_terminal_size().columns - len("usage: ")),
description="Show the next action in your todo.txt. The next action is selected from the tasks in the "
"todo.txt file based on task properties such as priority, due date, and creation date. Limit "
Expand Down Expand Up @@ -67,9 +67,6 @@ def add_input_options(self) -> None:
"-f", "--file", action="append", metavar="<todo.txt>", default=self.__default_filenames[:], type=str,
help="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)")
input_group.add_argument(
"-t", "--time-travel", metavar="<date>", type=date_type, nargs="?", const="tomorrow",
help="time travel to the given date and show the next action(s) at that date (default: tomorrow)")

def add_output_options(self) -> None:
"""Add the output/styling options to the parser."""
Expand Down Expand Up @@ -138,9 +135,6 @@ def parse_args(self, args=None, namespace=None) -> argparse.Namespace:
namespace.excluded_contexts = subset(namespace.filters, "-@")
namespace.excluded_projects = subset(namespace.filters, "-+")
self.validate_arguments(namespace)
if namespace.time_travel and namespace.due:
# Apply time travel to options that take a date argument (which currently is only --due)
namespace.due += namespace.time_travel - datetime.date.today()
if getattr(namespace, "config_file", self.get_default("config_file")) is not None:
self.process_config_file(namespace)
self.fix_filenames(namespace)
Expand Down
2 changes: 0 additions & 2 deletions next_action/output/__init__.py
Expand Up @@ -51,8 +51,6 @@ def render_arguments(argument_type: str, tasks: todotxt.Tasks) -> str:
"""Return the argument for tab completion."""
argument_type = argument_type.replace("_", "-") # Undo escaping
argument_values: Iterable[str]
if argument_type in ("--time-travel", "-t"):
return "tomorrow yesterday Monday Tuesday Wednesday Thursday Friday Saturday Sunday"
if argument_type in ("--reference", "-r"):
argument_values = arguments.parser.REFERENCE_CHOICES
elif argument_type in ("--style", "-s"):
Expand Down
5 changes: 2 additions & 3 deletions next_action/pick_action.py
Expand Up @@ -22,8 +22,7 @@ def next_actions(tasks: todotxt.Tasks, arguments: argparse.Namespace) -> todotxt
excluded_projects = arguments.excluded_projects

# First, get the potential next actions by filtering out tasks with a future creation date or threshold date
time_travel_date = arguments.time_travel or datetime.date.today()
eligible_tasks = filter(lambda task: not task.is_future(time_travel_date), tasks)
eligible_tasks = filter(lambda task: not task.is_future(), tasks)
# Then, exclude tasks that have an excluded context
if excluded_contexts:
eligible_tasks = filter(lambda task: not excluded_contexts & task.contexts(), eligible_tasks)
Expand All @@ -38,7 +37,7 @@ def next_actions(tasks: todotxt.Tasks, arguments: argparse.Namespace) -> todotxt
eligible_tasks = filter(lambda task: projects & task.projects(), eligible_tasks)
# If the user only wants to see overdue tasks, filter out non-overdue tasks
if arguments.overdue:
eligible_tasks = filter(lambda task: task.is_overdue(time_travel_date), eligible_tasks)
eligible_tasks = filter(lambda task: task.is_overdue(), eligible_tasks)
# If the user only wants to see tasks due before a due date, filter out non-due tasks
if arguments.due:
eligible_tasks = filter(lambda task: task.is_due(arguments.due), eligible_tasks)
Expand Down
9 changes: 4 additions & 5 deletions next_action/todotxt/task.py
Expand Up @@ -71,9 +71,9 @@ def is_due(self, due_date: datetime.date) -> bool:
task_due_date = self.due_date()
return task_due_date <= due_date if task_due_date else False

def is_future(self, today: datetime.date = None) -> bool:
def is_future(self) -> bool:
"""Return whether the task is a future task, i.e. has a creation or threshold date in the future."""
today = today or datetime.date.today()
today = datetime.date.today()
creation_date = self.creation_date()
if creation_date:
return creation_date > today
Expand All @@ -82,11 +82,10 @@ def is_future(self, today: datetime.date = None) -> bool:
return threshold_date > today
return False

def is_overdue(self, today: datetime.date = None) -> bool:
def is_overdue(self) -> bool:
"""Return whether the task is overdue, i.e. whether it has a due date in the past."""
today = today or datetime.date.today()
due_date = self.due_date()
return due_date < today if due_date else False
return due_date < datetime.date.today() if due_date else False

def is_blocked(self) -> bool:
"""Return whether a task is blocked, i.e. whether it has (uncompleted) child tasks."""
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Expand Up @@ -3,7 +3,7 @@ sonar.projectKey=fniessink:next-action

# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=Next-action
sonar.projectVersion=1.9.0
sonar.projectVersion=1.10.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
Expand Down
9 changes: 9 additions & 0 deletions tests/features/due.feature
Expand Up @@ -18,6 +18,15 @@ Feature: limit the next actions by due date
When the user asks for the next action over due
Then Next-action shows the user the next action over due

Scenario: one task due on specific date
Given a todo.txt with
"""
(A) Task A
(B) Task B due:2018-11-01
"""
When the user asks for the next action due 2018-11-01
Then Next-action shows the user the next action "(B) Task B due:2018-11-01"

Scenario: invalid date
When the user asks for the next action with an invalid due date
Then Next-action tells the user the due date is invalid
Expand Down
8 changes: 1 addition & 7 deletions tests/features/steps/show_next_action.py
Expand Up @@ -76,7 +76,7 @@ def next_action_from_file(context, filename):
@when("the user asks for the next action due {due_date}")
def next_action_due(context, due_date):
"""Add the due argument."""
context.arguments.extend(["--due", today() if due_date == "today" else tomorrow()])
context.arguments.extend(["--due", due_date])


@when("the user asks for the next action over due")
Expand Down Expand Up @@ -181,12 +181,6 @@ def next_action_not_for_project(context, projects):
context.arguments.extend([f"-+{p}" for p in projects])


@when("the user wants to pretend it's {some_date}")
def time_travel_tomorrow(context, some_date):
"""Add the time travel argument."""
context.arguments.extend(["--time-travel", some_date])


@when("the user asks for {number} next actions")
def ask_next_actions(context, number):
"""Add either the number of the all command line option to the command line arguments."""
Expand Down