-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a1fb4b0
commit 733fe74
Showing
6 changed files
with
192 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from pathlib import Path | ||
from datetime import date, timedelta | ||
from today.cli import build_parser, parse_args, CliArgs | ||
|
||
|
||
class TestCli: | ||
parser = build_parser() | ||
|
||
def test_cli_argparse0(self) -> None: | ||
cli_args = parse_args(self.parser, []) | ||
assert cli_args == CliArgs(task_dir=Path.cwd(), today=date.today(), lookahead_days=timedelta(days=0), task_id=None) | ||
|
||
def test_cli_argparse1(self) -> None: | ||
cli_args = parse_args(self.parser, ["--dir", "example/"]) | ||
assert cli_args == CliArgs(task_dir=Path.cwd() / "example", today=date.today(), lookahead_days=timedelta(days=0), task_id=None) | ||
|
||
def test_cli_argparse2(self) -> None: | ||
cli_args = parse_args(self.parser, ["--days", "10"]) | ||
assert cli_args == CliArgs(task_dir=Path.cwd(), today=date.today(), lookahead_days=timedelta(days=10), task_id=None) | ||
|
||
def test_cli_argparse3(self) -> None: | ||
cli_args = parse_args(self.parser, ["--today", "1/2/2022"]) | ||
assert cli_args == CliArgs(task_dir=Path.cwd(), today=date(2022, 1, 2), lookahead_days=timedelta(days=0), task_id=None) | ||
|
||
def test_cli_argparse4(self) -> None: | ||
cli_args = parse_args(self.parser, ["--today", "1/2/2022", "3"]) | ||
assert cli_args == CliArgs(task_dir=Path.cwd(), today=date(2022, 1, 2), lookahead_days=timedelta(days=0), task_id=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import sys | ||
from pathlib import Path | ||
import subprocess | ||
|
||
from today.cli import build_parser, parse_args, parse_task_files | ||
|
||
|
||
def run(args) -> None: | ||
parser = build_parser() | ||
cli_args = parse_args(parser, args) | ||
task_file = Path("/tmp/task") | ||
|
||
if cli_args.task_id is None: | ||
task_file.write_text("") | ||
else: | ||
tasks = parse_task_files(cli_args) | ||
task = tasks[cli_args.task_id] | ||
path = " → ".join(task.path) | ||
task_snippet = f"<span color='white'><span weight='bold'>Current Task -</span> {path} <span weight='bold'>-</span> {task.title}</span>" | ||
Path("/tmp/task").write_text(task_snippet) | ||
# https://i3wm.org/docs/i3status.html | ||
|
||
subprocess.run("killall -USR1 i3status", shell=True) | ||
sys.exit(0) | ||
|
||
|
||
def main(): | ||
sys.exit(run(sys.argv[1:])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import sys | ||
|
||
from rich.console import Console | ||
|
||
from today.cli import build_parser, parse_args, parse_task_files, maybe_display_specific_task, tasks_to_tree | ||
|
||
|
||
def run(args) -> None: | ||
parser = build_parser() | ||
cli_args = parse_args(parser, args) | ||
console = Console() | ||
|
||
tasks = parse_task_files(cli_args) | ||
maybe_display_specific_task(cli_args, tasks, console) # If a specific task is displayed, the program will exit | ||
|
||
tree = tasks_to_tree(cli_args, tasks) | ||
console.print("") | ||
console.print(tree) | ||
console.print("") | ||
|
||
|
||
def main(): | ||
sys.exit(run(sys.argv[1:])) |