tcal-tui 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tcal_tui-0.1.0/.gitignore +13 -0
- tcal_tui-0.1.0/LICENSE +21 -0
- tcal_tui-0.1.0/PKG-INFO +130 -0
- tcal_tui-0.1.0/README.md +101 -0
- tcal_tui-0.1.0/pyproject.toml +93 -0
- tcal_tui-0.1.0/tcal/__init__.py +1 -0
- tcal_tui-0.1.0/tcal/__main__.py +205 -0
- tcal_tui-0.1.0/tcal/background.py +76 -0
- tcal_tui-0.1.0/tcal/colors.py +11 -0
- tcal_tui-0.1.0/tcal/config.py +223 -0
- tcal_tui-0.1.0/tcal/credentials.py +48 -0
- tcal_tui-0.1.0/tcal/dates.py +159 -0
- tcal_tui-0.1.0/tcal/default_config.toml +86 -0
- tcal_tui-0.1.0/tcal/doctor.py +129 -0
- tcal_tui-0.1.0/tcal/ics.py +249 -0
- tcal_tui-0.1.0/tcal/model.py +75 -0
- tcal_tui-0.1.0/tcal/paths.py +56 -0
- tcal_tui-0.1.0/tcal/providers/__init__.py +0 -0
- tcal_tui-0.1.0/tcal/providers/base.py +52 -0
- tcal_tui-0.1.0/tcal/providers/fake.py +225 -0
- tcal_tui-0.1.0/tcal/providers/icloud.py +286 -0
- tcal_tui-0.1.0/tcal/providers/ics_url.py +86 -0
- tcal_tui-0.1.0/tcal/quickadd.py +560 -0
- tcal_tui-0.1.0/tcal/recurrence.py +104 -0
- tcal_tui-0.1.0/tcal/repeat.py +58 -0
- tcal_tui-0.1.0/tcal/source.py +81 -0
- tcal_tui-0.1.0/tcal/store.py +457 -0
- tcal_tui-0.1.0/tcal/sync.py +172 -0
- tcal_tui-0.1.0/tcal/synclog.py +66 -0
- tcal_tui-0.1.0/tcal/tz.py +31 -0
- tcal_tui-0.1.0/tcal/ui/__init__.py +0 -0
- tcal_tui-0.1.0/tcal/ui/app.py +708 -0
- tcal_tui-0.1.0/tcal/ui/calgrid.py +53 -0
- tcal_tui-0.1.0/tcal/ui/canvas.py +54 -0
- tcal_tui-0.1.0/tcal/ui/clipboard.py +87 -0
- tcal_tui-0.1.0/tcal/ui/editing.py +258 -0
- tcal_tui-0.1.0/tcal/ui/flash.py +140 -0
- tcal_tui-0.1.0/tcal/ui/formvalues.py +195 -0
- tcal_tui-0.1.0/tcal/ui/keys.py +54 -0
- tcal_tui-0.1.0/tcal/ui/messages.py +26 -0
- tcal_tui-0.1.0/tcal/ui/screens/__init__.py +1 -0
- tcal_tui-0.1.0/tcal/ui/screens/event_detail.py +242 -0
- tcal_tui-0.1.0/tcal/ui/screens/event_form.py +363 -0
- tcal_tui-0.1.0/tcal/ui/screens/event_prompt.py +212 -0
- tcal_tui-0.1.0/tcal/ui/screens/goto.py +35 -0
- tcal_tui-0.1.0/tcal/ui/screens/help.py +165 -0
- tcal_tui-0.1.0/tcal/ui/screens/main.py +15 -0
- tcal_tui-0.1.0/tcal/ui/screens/prompt.py +80 -0
- tcal_tui-0.1.0/tcal/ui/screens/search.py +124 -0
- tcal_tui-0.1.0/tcal/ui/screens/sync_log.py +93 -0
- tcal_tui-0.1.0/tcal/ui/state.py +92 -0
- tcal_tui-0.1.0/tcal/ui/styles.tcss +343 -0
- tcal_tui-0.1.0/tcal/ui/sync_status.py +32 -0
- tcal_tui-0.1.0/tcal/ui/theme.py +162 -0
- tcal_tui-0.1.0/tcal/ui/timelayout.py +285 -0
- tcal_tui-0.1.0/tcal/ui/timepaint.py +447 -0
- tcal_tui-0.1.0/tcal/ui/undo.py +65 -0
- tcal_tui-0.1.0/tcal/ui/widgets/__init__.py +0 -0
- tcal_tui-0.1.0/tcal/ui/widgets/base.py +85 -0
- tcal_tui-0.1.0/tcal/ui/widgets/calendar_list.py +99 -0
- tcal_tui-0.1.0/tcal/ui/widgets/day_cursor.py +28 -0
- tcal_tui-0.1.0/tcal/ui/widgets/minical.py +90 -0
- tcal_tui-0.1.0/tcal/ui/widgets/minimonth.py +84 -0
- tcal_tui-0.1.0/tcal/ui/widgets/month_view.py +272 -0
- tcal_tui-0.1.0/tcal/ui/widgets/schedule_view.py +360 -0
- tcal_tui-0.1.0/tcal/ui/widgets/statusbar.py +90 -0
- tcal_tui-0.1.0/tcal/ui/widgets/timegrid.py +705 -0
- tcal_tui-0.1.0/tcal/ui/widgets/view_switcher.py +80 -0
- tcal_tui-0.1.0/tcal/ui/widgets/year_view.py +173 -0
tcal_tui-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Georg Slamanig
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
tcal_tui-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: tcal-tui
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A minimal, keyboard-based TUI calendar that syncs with iCloud.
|
|
5
|
+
Project-URL: Homepage, https://github.com/gslama12/tcal
|
|
6
|
+
Project-URL: Documentation, https://gslama12.github.io/tcal/
|
|
7
|
+
Project-URL: Repository, https://github.com/gslama12/tcal
|
|
8
|
+
Project-URL: Issues, https://github.com/gslama12/tcal/issues
|
|
9
|
+
Author: Georg Slamanig
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: caldav,calendar,icloud,terminal,textual,tui,vim
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
16
|
+
Classifier: Operating System :: MacOS
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
20
|
+
Classifier: Topic :: Office/Business :: Scheduling
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: caldav<4,>=1.4.0
|
|
23
|
+
Requires-Dist: click>=8.1.8
|
|
24
|
+
Requires-Dist: icalendar<8,>=6.0.0
|
|
25
|
+
Requires-Dist: keyring>=25.0.0
|
|
26
|
+
Requires-Dist: python-dateutil>=2.9.0.post0
|
|
27
|
+
Requires-Dist: textual<9,>=6.1.0
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# tcal
|
|
31
|
+
|
|
32
|
+
[](https://gslama12.github.io/tcal/)
|
|
33
|
+
[](https://pypi.org/project/tcal-tui/)
|
|
34
|
+
[](https://github.com/gslama12/tcal/blob/main/LICENSE)
|
|
35
|
+
|
|
36
|
+
A keyboard-driven calendar for the terminal that syncs with iCloud: vim-like keys, events
|
|
37
|
+
typed in words and a familiar layout. It works offline too: edits are queued and
|
|
38
|
+
synced in the background. Built with [Textual](https://textual.textualize.io/).
|
|
39
|
+
|
|
40
|
+
<p align="center">
|
|
41
|
+
<img src="https://raw.githubusercontent.com/gslama12/tcal/main/site/docs/public/demo.gif" alt="tcal" width="900">
|
|
42
|
+
</p>
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
- **Four views** — week (`w`, zoom with `+` / `-`), month (`m`), year (`Y`) and schedule (`s`), next to a sidebar with a mini month (`M`) and your calendars (`c`, `space` shows or hides one).
|
|
47
|
+
- **Events in words** — `a` types a new event in one line, like `Lunch with Anna tomorrow 12:30-13:30 @Cafe #personal` or `Gym every tue 18:00 for 1h`, with a live preview ([syntax](https://gslama12.github.io/tcal/guide/typing-events)).
|
|
48
|
+
- **Event form** — `e` edits an event [field by field](https://gslama12.github.io/tcal/guide/editing-events); recurring events ask for "this event" or "all events", invitees and alerts are kept.
|
|
49
|
+
- **Event navigation** — in the week, `h` `j` `k` `l` jump from event to event; `v` switches to a grid cursor for empty slots.
|
|
50
|
+
- **Flash jumps** — `f` labels every event and slot of the week on screen; type a label and the cursor is there.
|
|
51
|
+
- **Move and resize** — `J` / `K` move a timed event by 15 minutes, `<` / `>` by a day; `o` resizes it.
|
|
52
|
+
- **Copy and paste** — `y` / `p` copy and paste, `D` duplicates to the next day; mark several events with `tab` to copy them together.
|
|
53
|
+
- **Undo** — `u` / `ctrl+r` undo and redo the last 20 changes, on iCloud too.
|
|
54
|
+
- **Go to and search** — `g` jumps to `fri`, `+2w`, `24.12.` or `dec`; `/` searches your events.
|
|
55
|
+
- **Subscriptions** — holidays, sports and other read-only calendars from any iCalendar URL.
|
|
56
|
+
|
|
57
|
+
> [!TIP]
|
|
58
|
+
> **Press `?` for a list of every key**, always matching your config. More in the [documentation](https://gslama12.github.io/tcal/).
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## Install
|
|
62
|
+
|
|
63
|
+
Needs Python 3.11+ on macOS, Linux or WSL. Published on PyPI as
|
|
64
|
+
[`tcal-tui`](https://pypi.org/project/tcal-tui/) (the name `tcal` was taken);
|
|
65
|
+
the command is still `tcal`.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
uv tool install tcal-tui # or: pipx install tcal-tui
|
|
69
|
+
tcal --demo # sample data, no account needed
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Update with `uv tool upgrade tcal-tui` (or `pipx upgrade tcal-tui`). Also check out the [installation guide](https://gslama12.github.io/tcal/guide/installation) and
|
|
73
|
+
[getting started](https://gslama12.github.io/tcal/guide/getting-started).
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
## iCloud setup
|
|
77
|
+
|
|
78
|
+
1. Create an **app-specific password** at [appleid.apple.com](https://appleid.apple.com) →
|
|
79
|
+
*Sign-In and Security* → *App-Specific Passwords* (your normal Apple ID password won't work).
|
|
80
|
+
2. Run `tcal login` and enter your Apple ID e-mail and that password, which is kept in the
|
|
81
|
+
system keyring (macOS Keychain).
|
|
82
|
+
3. Start `tcal`.
|
|
83
|
+
|
|
84
|
+
If something doesn't work, `tcal doctor` checks the setup step by step. See
|
|
85
|
+
[iCloud](https://gslama12.github.io/tcal/guide/icloud) and
|
|
86
|
+
[Troubleshooting](https://gslama12.github.io/tcal/reference/troubleshooting).
|
|
87
|
+
|
|
88
|
+
> [!TIP]
|
|
89
|
+
> For Google Calendar support, just ask your agent to write it and open a PR. Currently only Apple Calendar is supported.
|
|
90
|
+
|
|
91
|
+
## Configuration
|
|
92
|
+
|
|
93
|
+
Keys, theme, views, sync and subscriptions are set in `~/.config/tcal/config.toml`, on top of the
|
|
94
|
+
[defaults](https://github.com/gslama12/tcal/blob/main/tcal/default_config.toml). `tcal config edit` opens it, `tcal config check` validates it.
|
|
95
|
+
|
|
96
|
+
```toml
|
|
97
|
+
[theme]
|
|
98
|
+
name = "nord" # default: tokyo-night
|
|
99
|
+
|
|
100
|
+
[keys]
|
|
101
|
+
new_event = ["n"] # replaces all default keys of that action
|
|
102
|
+
|
|
103
|
+
[[subscription]]
|
|
104
|
+
name = "Feiertage"
|
|
105
|
+
url = "https://calendars.icloud.com/holidays/at_de.ics"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Every setting is listed in [Configuration](https://gslama12.github.io/tcal/reference/configuration),
|
|
109
|
+
every key in [Keybindings](https://gslama12.github.io/tcal/guide/keybindings).
|
|
110
|
+
|
|
111
|
+
> Setting `TCAL_HOME` keeps config and data in that one directory instead, giving a fully isolated instance.
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## Development
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
git clone https://github.com/gslama12/tcal
|
|
118
|
+
cd tcal
|
|
119
|
+
uv sync
|
|
120
|
+
uv run tcal --demo
|
|
121
|
+
uv run pytest -q
|
|
122
|
+
uv run ruff check && uv run ruff format --check && uv run mypy
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Tests need no network or keyring. Architecture and decisions are in [docs/PLAN.md](https://github.com/gslama12/tcal/blob/main/docs/PLAN.md).
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
[MIT](https://github.com/gslama12/tcal/blob/main/LICENSE)
|
tcal_tui-0.1.0/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# tcal
|
|
2
|
+
|
|
3
|
+
[](https://gslama12.github.io/tcal/)
|
|
4
|
+
[](https://pypi.org/project/tcal-tui/)
|
|
5
|
+
[](https://github.com/gslama12/tcal/blob/main/LICENSE)
|
|
6
|
+
|
|
7
|
+
A keyboard-driven calendar for the terminal that syncs with iCloud: vim-like keys, events
|
|
8
|
+
typed in words and a familiar layout. It works offline too: edits are queued and
|
|
9
|
+
synced in the background. Built with [Textual](https://textual.textualize.io/).
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://raw.githubusercontent.com/gslama12/tcal/main/site/docs/public/demo.gif" alt="tcal" width="900">
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **Four views** — week (`w`, zoom with `+` / `-`), month (`m`), year (`Y`) and schedule (`s`), next to a sidebar with a mini month (`M`) and your calendars (`c`, `space` shows or hides one).
|
|
18
|
+
- **Events in words** — `a` types a new event in one line, like `Lunch with Anna tomorrow 12:30-13:30 @Cafe #personal` or `Gym every tue 18:00 for 1h`, with a live preview ([syntax](https://gslama12.github.io/tcal/guide/typing-events)).
|
|
19
|
+
- **Event form** — `e` edits an event [field by field](https://gslama12.github.io/tcal/guide/editing-events); recurring events ask for "this event" or "all events", invitees and alerts are kept.
|
|
20
|
+
- **Event navigation** — in the week, `h` `j` `k` `l` jump from event to event; `v` switches to a grid cursor for empty slots.
|
|
21
|
+
- **Flash jumps** — `f` labels every event and slot of the week on screen; type a label and the cursor is there.
|
|
22
|
+
- **Move and resize** — `J` / `K` move a timed event by 15 minutes, `<` / `>` by a day; `o` resizes it.
|
|
23
|
+
- **Copy and paste** — `y` / `p` copy and paste, `D` duplicates to the next day; mark several events with `tab` to copy them together.
|
|
24
|
+
- **Undo** — `u` / `ctrl+r` undo and redo the last 20 changes, on iCloud too.
|
|
25
|
+
- **Go to and search** — `g` jumps to `fri`, `+2w`, `24.12.` or `dec`; `/` searches your events.
|
|
26
|
+
- **Subscriptions** — holidays, sports and other read-only calendars from any iCalendar URL.
|
|
27
|
+
|
|
28
|
+
> [!TIP]
|
|
29
|
+
> **Press `?` for a list of every key**, always matching your config. More in the [documentation](https://gslama12.github.io/tcal/).
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
Needs Python 3.11+ on macOS, Linux or WSL. Published on PyPI as
|
|
35
|
+
[`tcal-tui`](https://pypi.org/project/tcal-tui/) (the name `tcal` was taken);
|
|
36
|
+
the command is still `tcal`.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
uv tool install tcal-tui # or: pipx install tcal-tui
|
|
40
|
+
tcal --demo # sample data, no account needed
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Update with `uv tool upgrade tcal-tui` (or `pipx upgrade tcal-tui`). Also check out the [installation guide](https://gslama12.github.io/tcal/guide/installation) and
|
|
44
|
+
[getting started](https://gslama12.github.io/tcal/guide/getting-started).
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## iCloud setup
|
|
48
|
+
|
|
49
|
+
1. Create an **app-specific password** at [appleid.apple.com](https://appleid.apple.com) →
|
|
50
|
+
*Sign-In and Security* → *App-Specific Passwords* (your normal Apple ID password won't work).
|
|
51
|
+
2. Run `tcal login` and enter your Apple ID e-mail and that password, which is kept in the
|
|
52
|
+
system keyring (macOS Keychain).
|
|
53
|
+
3. Start `tcal`.
|
|
54
|
+
|
|
55
|
+
If something doesn't work, `tcal doctor` checks the setup step by step. See
|
|
56
|
+
[iCloud](https://gslama12.github.io/tcal/guide/icloud) and
|
|
57
|
+
[Troubleshooting](https://gslama12.github.io/tcal/reference/troubleshooting).
|
|
58
|
+
|
|
59
|
+
> [!TIP]
|
|
60
|
+
> For Google Calendar support, just ask your agent to write it and open a PR. Currently only Apple Calendar is supported.
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
Keys, theme, views, sync and subscriptions are set in `~/.config/tcal/config.toml`, on top of the
|
|
65
|
+
[defaults](https://github.com/gslama12/tcal/blob/main/tcal/default_config.toml). `tcal config edit` opens it, `tcal config check` validates it.
|
|
66
|
+
|
|
67
|
+
```toml
|
|
68
|
+
[theme]
|
|
69
|
+
name = "nord" # default: tokyo-night
|
|
70
|
+
|
|
71
|
+
[keys]
|
|
72
|
+
new_event = ["n"] # replaces all default keys of that action
|
|
73
|
+
|
|
74
|
+
[[subscription]]
|
|
75
|
+
name = "Feiertage"
|
|
76
|
+
url = "https://calendars.icloud.com/holidays/at_de.ics"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Every setting is listed in [Configuration](https://gslama12.github.io/tcal/reference/configuration),
|
|
80
|
+
every key in [Keybindings](https://gslama12.github.io/tcal/guide/keybindings).
|
|
81
|
+
|
|
82
|
+
> Setting `TCAL_HOME` keeps config and data in that one directory instead, giving a fully isolated instance.
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
## Development
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
git clone https://github.com/gslama12/tcal
|
|
89
|
+
cd tcal
|
|
90
|
+
uv sync
|
|
91
|
+
uv run tcal --demo
|
|
92
|
+
uv run pytest -q
|
|
93
|
+
uv run ruff check && uv run ruff format --check && uv run mypy
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Tests need no network or keyring. Architecture and decisions are in [docs/PLAN.md](https://github.com/gslama12/tcal/blob/main/docs/PLAN.md).
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
[MIT](https://github.com/gslama12/tcal/blob/main/LICENSE)
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
# "tcal" is taken on PyPI by an unrelated project, so the distribution is
|
|
3
|
+
# tcal-tui; the import package and the command both stay `tcal`.
|
|
4
|
+
name = "tcal-tui"
|
|
5
|
+
version = "0.1.0"
|
|
6
|
+
description = "A minimal, keyboard-based TUI calendar that syncs with iCloud."
|
|
7
|
+
requires-python = ">=3.11"
|
|
8
|
+
authors = [{ name = "Georg Slamanig" }]
|
|
9
|
+
license = "MIT"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
keywords = ["calendar", "tui", "terminal", "icloud", "caldav", "vim", "textual"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Environment :: Console",
|
|
15
|
+
"Intended Audience :: End Users/Desktop",
|
|
16
|
+
"Operating System :: MacOS",
|
|
17
|
+
"Operating System :: POSIX :: Linux",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
20
|
+
"Topic :: Office/Business :: Scheduling",
|
|
21
|
+
]
|
|
22
|
+
# Upper bounds only on the majors most likely to break the app: users install
|
|
23
|
+
# from PyPI without uv.lock, so a new major would reach them untested. Raise a
|
|
24
|
+
# bound after testing against the new major.
|
|
25
|
+
dependencies = [
|
|
26
|
+
"caldav>=1.4.0,<4",
|
|
27
|
+
"click>=8.1.8",
|
|
28
|
+
"icalendar>=6.0.0,<8",
|
|
29
|
+
"keyring>=25.0.0",
|
|
30
|
+
"python-dateutil>=2.9.0.post0",
|
|
31
|
+
"textual>=6.1.0,<9",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/gslama12/tcal"
|
|
36
|
+
Documentation = "https://gslama12.github.io/tcal/"
|
|
37
|
+
Repository = "https://github.com/gslama12/tcal"
|
|
38
|
+
Issues = "https://github.com/gslama12/tcal/issues"
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
tcal = "tcal.__main__:main"
|
|
42
|
+
|
|
43
|
+
[dependency-groups]
|
|
44
|
+
dev = [
|
|
45
|
+
"mypy>=1.19.1",
|
|
46
|
+
"pytest>=8.4.2",
|
|
47
|
+
"pytest-asyncio>=1.2.0",
|
|
48
|
+
"ruff>=0.13.1",
|
|
49
|
+
"textual-dev>=1.7.0",
|
|
50
|
+
"types-python-dateutil>=2.9.0.20260124",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[build-system]
|
|
54
|
+
requires = ["hatchling"]
|
|
55
|
+
build-backend = "hatchling.build"
|
|
56
|
+
|
|
57
|
+
[tool.hatch.build.targets.wheel]
|
|
58
|
+
packages = ["tcal"]
|
|
59
|
+
|
|
60
|
+
# Without this the sdist ships the whole repo (docs site, tests, scripts)
|
|
61
|
+
[tool.hatch.build.targets.sdist]
|
|
62
|
+
include = ["/tcal", "/README.md", "/LICENSE"]
|
|
63
|
+
|
|
64
|
+
[tool.pytest.ini_options]
|
|
65
|
+
asyncio_mode = "auto"
|
|
66
|
+
asyncio_default_fixture_loop_scope = "function"
|
|
67
|
+
testpaths = ["tests"]
|
|
68
|
+
addopts = "--strict-markers"
|
|
69
|
+
|
|
70
|
+
[tool.ruff]
|
|
71
|
+
line-length = 100
|
|
72
|
+
|
|
73
|
+
[tool.ruff.lint]
|
|
74
|
+
# An explicit set rather than ruff's defaults, so upgrades don't change the rules
|
|
75
|
+
select = [
|
|
76
|
+
"E4", "E7", "E9", "F", # pycodestyle errors + pyflakes
|
|
77
|
+
"I", # import sorting
|
|
78
|
+
"B", # bugbear: likely bugs
|
|
79
|
+
"SIM", # simplifications
|
|
80
|
+
"PIE", # unnecessary code
|
|
81
|
+
"RUF100", # stale noqa comments
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
[tool.mypy]
|
|
85
|
+
files = ["tcal", "tests"]
|
|
86
|
+
python_version = "3.11"
|
|
87
|
+
check_untyped_defs = true
|
|
88
|
+
warn_unused_ignores = true
|
|
89
|
+
warn_redundant_casts = true
|
|
90
|
+
|
|
91
|
+
[[tool.mypy.overrides]]
|
|
92
|
+
module = ["lxml", "lxml.*"]
|
|
93
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""tcal: a terminal calendar that syncs with iCloud."""
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
"""Command line: ``tcal`` starts the TUI; ``tcal --demo`` uses sample data.
|
|
2
|
+
|
|
3
|
+
``tcal login`` stores the iCloud account, ``tcal sync`` syncs once,
|
|
4
|
+
``tcal calendars`` lists the account's calendars, ``tcal doctor`` checks the
|
|
5
|
+
connection step by step and ``tcal config path|edit|check``
|
|
6
|
+
helps with the config file.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from collections.abc import Iterator
|
|
10
|
+
from contextlib import contextmanager
|
|
11
|
+
from functools import partial
|
|
12
|
+
|
|
13
|
+
import click
|
|
14
|
+
|
|
15
|
+
from tcal import paths
|
|
16
|
+
from tcal.config import (
|
|
17
|
+
Config,
|
|
18
|
+
ConfigError,
|
|
19
|
+
commented_defaults,
|
|
20
|
+
describe_conflicts,
|
|
21
|
+
key_conflicts,
|
|
22
|
+
load_config,
|
|
23
|
+
save_apple_id,
|
|
24
|
+
)
|
|
25
|
+
from tcal.credentials import CredentialsError, get_password, store_password
|
|
26
|
+
from tcal.providers.base import Provider
|
|
27
|
+
from tcal.synclog import log_to_file
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def connect(config: Config, apple_id: str | None = None, password: str | None = None) -> Provider:
|
|
31
|
+
"""The configured account's provider; ``apple_id``/``password`` override the config."""
|
|
32
|
+
from tcal.providers.icloud import ICloudProvider
|
|
33
|
+
|
|
34
|
+
account = config.account
|
|
35
|
+
apple_id = apple_id or account.apple_id
|
|
36
|
+
if not apple_id:
|
|
37
|
+
raise click.ClickException("no account set up: run `tcal login` (or try `tcal --demo`)")
|
|
38
|
+
try:
|
|
39
|
+
password = password or get_password(account)
|
|
40
|
+
except CredentialsError as e:
|
|
41
|
+
raise click.ClickException(str(e)) from None
|
|
42
|
+
if not password:
|
|
43
|
+
raise click.ClickException(
|
|
44
|
+
"no password found in the keyring, password_cmd or $TCAL_PASSWORD; run `tcal login`"
|
|
45
|
+
)
|
|
46
|
+
return ICloudProvider.connect(apple_id, password, account.caldav_url)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _feeds(config: Config) -> Provider | None:
|
|
50
|
+
"""The ``[[subscription]]`` feeds' provider, None without any."""
|
|
51
|
+
from tcal.providers.ics_url import IcsUrlProvider
|
|
52
|
+
|
|
53
|
+
return IcsUrlProvider(config.subscriptions) if config.subscriptions else None
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@contextmanager
|
|
57
|
+
def _reported(what: str) -> Iterator[None]:
|
|
58
|
+
"""Turn provider/network errors into a clean CLI error."""
|
|
59
|
+
try:
|
|
60
|
+
yield
|
|
61
|
+
except Exception as e:
|
|
62
|
+
raise click.ClickException(f"{what}: {e}") from None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def _config() -> Config:
|
|
66
|
+
try:
|
|
67
|
+
return load_config()
|
|
68
|
+
except ConfigError as e:
|
|
69
|
+
raise click.ClickException(f"config: {e}") from None
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
@click.group(invoke_without_command=True)
|
|
73
|
+
@click.option("--demo", is_flag=True, help="Run with built-in sample data (no account needed).")
|
|
74
|
+
@click.pass_context
|
|
75
|
+
def cli(ctx: click.Context, demo: bool) -> None:
|
|
76
|
+
"""A minimal, keyboard-based TUI calendar."""
|
|
77
|
+
if ctx.invoked_subcommand is not None:
|
|
78
|
+
return
|
|
79
|
+
config = _config()
|
|
80
|
+
log_to_file(paths.log_file())
|
|
81
|
+
|
|
82
|
+
from tcal.background import finish_sync
|
|
83
|
+
from tcal.providers.fake import FakeProvider, demo_feed
|
|
84
|
+
from tcal.source import StoreSource
|
|
85
|
+
from tcal.store import Store
|
|
86
|
+
from tcal.sync import sync_job
|
|
87
|
+
from tcal.ui.app import TcalApp
|
|
88
|
+
|
|
89
|
+
if demo:
|
|
90
|
+
# A throwaway cache, fresh each run, so the demo never touches the real one.
|
|
91
|
+
database = paths.demo_database_file()
|
|
92
|
+
database.unlink(missing_ok=True)
|
|
93
|
+
sync = sync_job(FakeProvider(), database, config.sync, subscriptions=demo_feed())
|
|
94
|
+
sync() # fill the cache before the first frame
|
|
95
|
+
else:
|
|
96
|
+
database = paths.database_file()
|
|
97
|
+
sync = sync_job(connect(config), database, config.sync, subscriptions=_feeds(config))
|
|
98
|
+
with Store(database) as store:
|
|
99
|
+
app = TcalApp(StoreSource(store), config, sync=sync)
|
|
100
|
+
app.run()
|
|
101
|
+
if app.sync_runner is not None:
|
|
102
|
+
finish_sync(app.sync_runner, store.pending_count, partial(click.echo, err=True))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@cli.command()
|
|
106
|
+
@click.option("--apple-id", prompt="Apple ID", help="Your Apple ID e-mail.")
|
|
107
|
+
@click.option(
|
|
108
|
+
"--password",
|
|
109
|
+
prompt="App-specific password (appleid.apple.com)",
|
|
110
|
+
hide_input=True,
|
|
111
|
+
help="An app-specific password, not your Apple ID password.",
|
|
112
|
+
)
|
|
113
|
+
def login(apple_id: str, password: str) -> None:
|
|
114
|
+
"""Verify an iCloud account and remember it (password in the system keyring)."""
|
|
115
|
+
provider = connect(_config(), apple_id, password)
|
|
116
|
+
with _reported("could not connect"):
|
|
117
|
+
calendars = provider.list_calendars()
|
|
118
|
+
try:
|
|
119
|
+
store_password(apple_id, password)
|
|
120
|
+
except CredentialsError as e:
|
|
121
|
+
click.echo(f"warning: {e}; set password_cmd or $TCAL_PASSWORD instead", err=True)
|
|
122
|
+
save_apple_id(apple_id)
|
|
123
|
+
click.echo(f"Logged in as {apple_id}: {len(calendars)} calendars.")
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@cli.command()
|
|
127
|
+
def sync() -> None:
|
|
128
|
+
"""Sync once with the server and print a summary."""
|
|
129
|
+
from tcal.sync import sync_job
|
|
130
|
+
|
|
131
|
+
config = _config()
|
|
132
|
+
log_to_file(paths.log_file())
|
|
133
|
+
job = sync_job(
|
|
134
|
+
connect(config), paths.database_file(), config.sync, subscriptions=_feeds(config)
|
|
135
|
+
)
|
|
136
|
+
with _reported("sync failed"):
|
|
137
|
+
summary = job()
|
|
138
|
+
for warning in summary.warnings:
|
|
139
|
+
click.echo(f"warning: {warning}", err=True)
|
|
140
|
+
click.echo(f"Synced: {summary}")
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@cli.command()
|
|
144
|
+
def calendars() -> None:
|
|
145
|
+
"""List the account's calendars."""
|
|
146
|
+
from tcal.doctor import calendar_line
|
|
147
|
+
|
|
148
|
+
provider = connect(_config())
|
|
149
|
+
with _reported("could not list calendars"):
|
|
150
|
+
found = provider.list_calendars()
|
|
151
|
+
for cal in found:
|
|
152
|
+
click.echo(calendar_line(cal))
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@cli.command()
|
|
156
|
+
def doctor() -> None:
|
|
157
|
+
"""Check the iCloud setup step by step (reads only, never writes)."""
|
|
158
|
+
from tcal import doctor as checks
|
|
159
|
+
|
|
160
|
+
if not checks.run(_config(), click.echo):
|
|
161
|
+
raise SystemExit(1)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@cli.group(name="config")
|
|
165
|
+
def config_group() -> None:
|
|
166
|
+
"""Show, edit or check the config file."""
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
@config_group.command()
|
|
170
|
+
def path() -> None:
|
|
171
|
+
"""Print the config file's path."""
|
|
172
|
+
click.echo(paths.config_file())
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
@config_group.command()
|
|
176
|
+
def edit() -> None:
|
|
177
|
+
"""Open the config in $EDITOR (created with the commented defaults if missing)."""
|
|
178
|
+
file = paths.config_file()
|
|
179
|
+
if not file.exists():
|
|
180
|
+
file.parent.mkdir(parents=True, exist_ok=True)
|
|
181
|
+
file.write_text(commented_defaults())
|
|
182
|
+
click.edit(filename=str(file))
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
@config_group.command()
|
|
186
|
+
def check() -> None:
|
|
187
|
+
"""Validate the config: unknown settings/actions, bad values, duplicate key bindings."""
|
|
188
|
+
from tcal.ui.theme import PALETTES
|
|
189
|
+
|
|
190
|
+
config = _config()
|
|
191
|
+
problems = describe_conflicts(key_conflicts(config))
|
|
192
|
+
if config.theme.name not in PALETTES:
|
|
193
|
+
problems.append(f"unknown theme {config.theme.name!r}; one of {', '.join(PALETTES)}")
|
|
194
|
+
if problems:
|
|
195
|
+
raise click.ClickException("\n".join(problems))
|
|
196
|
+
file = paths.config_file()
|
|
197
|
+
click.echo(f"{file}: OK" if file.exists() else f"no config file at {file} (defaults are used)")
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def main() -> None:
|
|
201
|
+
cli()
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
if __name__ == "__main__":
|
|
205
|
+
main()
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Background syncs, and finishing them after the TUI has closed.
|
|
2
|
+
|
|
3
|
+
``SyncRunner`` runs the app's syncs in daemon threads: unlike asyncio's executor threads
|
|
4
|
+
(which the event loop joins silently when it closes) nothing waits for them implicitly.
|
|
5
|
+
``finish_sync`` does, telling the user so; leaving early is safe, since ops stay queued
|
|
6
|
+
until the server has answered and the store's writes are transactions.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import logging
|
|
10
|
+
import threading
|
|
11
|
+
from collections.abc import Callable
|
|
12
|
+
from concurrent.futures import Future
|
|
13
|
+
|
|
14
|
+
from tcal.sync import SyncSummary
|
|
15
|
+
|
|
16
|
+
log = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
Job = Callable[[], SyncSummary]
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class SyncRunner:
|
|
22
|
+
def __init__(self, job: Job) -> None:
|
|
23
|
+
self.job = job
|
|
24
|
+
self.last: Future[SyncSummary] | None = None # the sync started last
|
|
25
|
+
|
|
26
|
+
def start(self) -> Future[SyncSummary]:
|
|
27
|
+
"""Run one sync in a thread of its own."""
|
|
28
|
+
future: Future[SyncSummary] = Future()
|
|
29
|
+
future.set_running_or_notify_cancel() # from here on it can't be cancelled
|
|
30
|
+
self.last = future
|
|
31
|
+
threading.Thread(target=self._run, args=(future,), name="sync", daemon=True).start()
|
|
32
|
+
return future
|
|
33
|
+
|
|
34
|
+
def _run(self, future: Future[SyncSummary]) -> None:
|
|
35
|
+
try:
|
|
36
|
+
result = self.job()
|
|
37
|
+
except BaseException as e: # like an executor: whoever waits gets it
|
|
38
|
+
future.set_exception(e)
|
|
39
|
+
else:
|
|
40
|
+
future.set_result(result)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def finish_sync(
|
|
44
|
+
runner: SyncRunner, pending_count: Callable[[], int], echo: Callable[[str], object]
|
|
45
|
+
) -> None:
|
|
46
|
+
"""Wait for the sync still running, if any, and push the edits made meanwhile.
|
|
47
|
+
|
|
48
|
+
``echo`` gets a line before and one after; ctrl+c stops waiting. With no sync running
|
|
49
|
+
it only mentions edits that could not be pushed (e.g. offline), if there are any.
|
|
50
|
+
"""
|
|
51
|
+
future = runner.last
|
|
52
|
+
if future is None or future.done():
|
|
53
|
+
if count := pending_count():
|
|
54
|
+
echo(f"tcal: {_queued(count)}")
|
|
55
|
+
return
|
|
56
|
+
try:
|
|
57
|
+
echo("tcal: syncing… (ctrl+c to quit without waiting)")
|
|
58
|
+
problems = future.result().problems()
|
|
59
|
+
if pending_count(): # edited during that sync
|
|
60
|
+
problems += runner.start().result().problems()
|
|
61
|
+
except KeyboardInterrupt:
|
|
62
|
+
count = pending_count()
|
|
63
|
+
left = _queued(count) if count else "the next start syncs again"
|
|
64
|
+
echo(f"\ntcal: sync not finished; {left}") # the terminal shows ^C on this line
|
|
65
|
+
except Exception as e:
|
|
66
|
+
log.error("sync failed: %s", e)
|
|
67
|
+
error = " ".join(str(e).split()) or type(e).__name__
|
|
68
|
+
count = pending_count()
|
|
69
|
+
echo(f"tcal: sync failed: {error}" + (f"; {_queued(count)}" if count else ""))
|
|
70
|
+
else:
|
|
71
|
+
echo(", ".join(["tcal: synced", *problems]))
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _queued(count: int) -> str:
|
|
75
|
+
changes = "1 change stays" if count == 1 else f"{count} changes stay"
|
|
76
|
+
return f"{changes} queued for the next start"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""Apple's calendar colours (the choices in iCloud's and Calendar.app's colour picker)."""
|
|
2
|
+
|
|
3
|
+
RED = "#FF2968"
|
|
4
|
+
ORANGE = "#FF9500"
|
|
5
|
+
YELLOW = "#FFCC00"
|
|
6
|
+
GREEN = "#63DA38"
|
|
7
|
+
BLUE = "#1BADF8"
|
|
8
|
+
PURPLE = "#CC73E1"
|
|
9
|
+
BROWN = "#A2845E"
|
|
10
|
+
|
|
11
|
+
APPLE_COLORS = (RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE, BROWN)
|