pebbenote-cli 0.6.1__py3-none-any.whl
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.
- pebbenote_cli/__init__.py +0 -0
- pebbenote_cli/__main__.py +3 -0
- pebbenote_cli/api.py +62 -0
- pebbenote_cli/auth.py +120 -0
- pebbenote_cli/cli.py +282 -0
- pebbenote_cli/client/__init__.py +8 -0
- pebbenote_cli/client/api/__init__.py +1 -0
- pebbenote_cli/client/api/actions/__init__.py +1 -0
- pebbenote_cli/client/api/actions/apply_action.py +166 -0
- pebbenote_cli/client/api/instructions/__init__.py +1 -0
- pebbenote_cli/client/api/instructions/list_instructions.py +127 -0
- pebbenote_cli/client/api/instructions/replace_instructions.py +204 -0
- pebbenote_cli/client/api/notes/__init__.py +1 -0
- pebbenote_cli/client/api/notes/create_note.py +173 -0
- pebbenote_cli/client/api/notes/delete_note.py +159 -0
- pebbenote_cli/client/api/notes/edit_note_by_id.py +197 -0
- pebbenote_cli/client/api/notes/get_note_by_id.py +184 -0
- pebbenote_cli/client/api/notes/list_notes.py +132 -0
- pebbenote_cli/client/api/notes/set_default_note.py +161 -0
- pebbenote_cli/client/api/sharing/__init__.py +1 -0
- pebbenote_cli/client/api/sharing/get_note_sharing.py +161 -0
- pebbenote_cli/client/api/sharing/get_shared_note.py +172 -0
- pebbenote_cli/client/api/sharing/join_shared_note.py +176 -0
- pebbenote_cli/client/api/sharing/make_note_private.py +167 -0
- pebbenote_cli/client/api/sharing/remove_note_member.py +173 -0
- pebbenote_cli/client/api/sharing/revoke_share_link.py +181 -0
- pebbenote_cli/client/api/sharing/share_note.py +202 -0
- pebbenote_cli/client/client.py +280 -0
- pebbenote_cli/client/errors.py +16 -0
- pebbenote_cli/client/models/__init__.py +47 -0
- pebbenote_cli/client/models/action_accepted_model.py +68 -0
- pebbenote_cli/client/models/action_edit_model.py +96 -0
- pebbenote_cli/client/models/action_model.py +105 -0
- pebbenote_cli/client/models/action_status.py +10 -0
- pebbenote_cli/client/models/http_validation_error.py +79 -0
- pebbenote_cli/client/models/instructions_conflict_model.py +75 -0
- pebbenote_cli/client/models/instructions_edit_model.py +69 -0
- pebbenote_cli/client/models/instructions_model.py +69 -0
- pebbenote_cli/client/models/note_access.py +10 -0
- pebbenote_cli/client/models/note_conflict_model.py +75 -0
- pebbenote_cli/client/models/note_member_model.py +86 -0
- pebbenote_cli/client/models/note_model.py +113 -0
- pebbenote_cli/client/models/note_sharing_model.py +94 -0
- pebbenote_cli/client/models/note_update_model.py +83 -0
- pebbenote_cli/client/models/note_view_model.py +143 -0
- pebbenote_cli/client/models/share_access.py +9 -0
- pebbenote_cli/client/models/share_create_model.py +69 -0
- pebbenote_cli/client/models/share_link_model.py +120 -0
- pebbenote_cli/client/models/shared_note_model.py +89 -0
- pebbenote_cli/client/models/validation_error.py +125 -0
- pebbenote_cli/client/models/validation_error_context.py +44 -0
- pebbenote_cli/client/types.py +54 -0
- pebbenote_cli/config.py +46 -0
- pebbenote_cli/editor.py +23 -0
- pebbenote_cli/errors.py +10 -0
- pebbenote_cli/http.py +36 -0
- pebbenote_cli/instructions.py +24 -0
- pebbenote_cli/merge.py +79 -0
- pebbenote_cli-0.6.1.dist-info/METADATA +129 -0
- pebbenote_cli-0.6.1.dist-info/RECORD +62 -0
- pebbenote_cli-0.6.1.dist-info/WHEEL +4 -0
- pebbenote_cli-0.6.1.dist-info/entry_points.txt +3 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"""Contains some shared types for properties"""
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping, MutableMapping
|
|
4
|
+
from http import HTTPStatus
|
|
5
|
+
from typing import IO, BinaryIO, Generic, Literal, TypeVar
|
|
6
|
+
|
|
7
|
+
from attrs import define
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Unset:
|
|
11
|
+
def __bool__(self) -> Literal[False]:
|
|
12
|
+
return False
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
UNSET: Unset = Unset()
|
|
16
|
+
|
|
17
|
+
# The types that `httpx.Client(files=)` can accept, copied from that library.
|
|
18
|
+
FileContent = IO[bytes] | bytes | str
|
|
19
|
+
FileTypes = (
|
|
20
|
+
# (filename, file (or bytes), content_type)
|
|
21
|
+
tuple[str | None, FileContent, str | None]
|
|
22
|
+
# (filename, file (or bytes), content_type, headers)
|
|
23
|
+
| tuple[str | None, FileContent, str | None, Mapping[str, str]]
|
|
24
|
+
)
|
|
25
|
+
RequestFiles = list[tuple[str, FileTypes]]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@define
|
|
29
|
+
class File:
|
|
30
|
+
"""Contains information for file uploads"""
|
|
31
|
+
|
|
32
|
+
payload: BinaryIO
|
|
33
|
+
file_name: str | None = None
|
|
34
|
+
mime_type: str | None = None
|
|
35
|
+
|
|
36
|
+
def to_tuple(self) -> FileTypes:
|
|
37
|
+
"""Return a tuple representation that httpx will accept for multipart/form-data"""
|
|
38
|
+
return self.file_name, self.payload, self.mime_type
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
T = TypeVar("T")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@define
|
|
45
|
+
class Response(Generic[T]):
|
|
46
|
+
"""A response from an endpoint"""
|
|
47
|
+
|
|
48
|
+
status_code: HTTPStatus
|
|
49
|
+
content: bytes
|
|
50
|
+
headers: MutableMapping[str, str]
|
|
51
|
+
parsed: T | None
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
__all__ = ["UNSET", "File", "FileTypes", "RequestFiles", "Response", "Unset"]
|
pebbenote_cli/config.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from dataclasses import dataclass
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
import tomllib
|
|
6
|
+
|
|
7
|
+
from pebbenote_cli.errors import CliError
|
|
8
|
+
|
|
9
|
+
CONFIG_HOME = Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config")
|
|
10
|
+
CONFIG_FILE = CONFIG_HOME / "pebbenote" / "config.toml"
|
|
11
|
+
|
|
12
|
+
STATE_HOME = Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local" / "state")
|
|
13
|
+
TOKEN_FILE = STATE_HOME / "pebbenote" / "tokens.json"
|
|
14
|
+
# An edit that could not be synced because its conflicts were left unresolved
|
|
15
|
+
UNRESOLVED_FILE = STATE_HOME / "pebbenote" / "unresolved.md"
|
|
16
|
+
|
|
17
|
+
DEFAULT_BACKEND_URL = "https://dev.grzegorzkoperwas.site"
|
|
18
|
+
DEFAULT_ISSUER = "https://auth.grzegorzkoperwas.site/realms/pebbenote"
|
|
19
|
+
|
|
20
|
+
DEFAULT_CONFIG = f"""\
|
|
21
|
+
# Pebbenote CLI configuration. For a local setup use:
|
|
22
|
+
# backend_url = "http://localhost:8000"
|
|
23
|
+
# issuer = "http://localhost:8080/realms/pebbenote"
|
|
24
|
+
backend_url = "{DEFAULT_BACKEND_URL}"
|
|
25
|
+
issuer = "{DEFAULT_ISSUER}"
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass
|
|
30
|
+
class Config:
|
|
31
|
+
backend_url: str
|
|
32
|
+
issuer: str
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def load_config() -> Config:
|
|
36
|
+
if not CONFIG_FILE.exists():
|
|
37
|
+
CONFIG_FILE.parent.mkdir(parents=True, exist_ok=True)
|
|
38
|
+
CONFIG_FILE.write_text(DEFAULT_CONFIG)
|
|
39
|
+
try:
|
|
40
|
+
data = tomllib.loads(CONFIG_FILE.read_text())
|
|
41
|
+
except tomllib.TOMLDecodeError as e:
|
|
42
|
+
raise CliError(f"Invalid config {CONFIG_FILE}: {e}") from e
|
|
43
|
+
return Config(
|
|
44
|
+
backend_url=data.get("backend_url", DEFAULT_BACKEND_URL).rstrip("/"),
|
|
45
|
+
issuer=data.get("issuer", DEFAULT_ISSUER).rstrip("/"),
|
|
46
|
+
)
|
pebbenote_cli/editor.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shlex
|
|
3
|
+
import subprocess
|
|
4
|
+
import tempfile
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from pebbenote_cli.errors import CliError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def edit_text(text):
|
|
11
|
+
editor = os.environ.get("EDITOR") or os.environ.get("VISUAL") or "vi"
|
|
12
|
+
with tempfile.NamedTemporaryFile(
|
|
13
|
+
"w", suffix=".md", prefix="pebbenote-", delete=False
|
|
14
|
+
) as f:
|
|
15
|
+
f.write(text)
|
|
16
|
+
path = f.name
|
|
17
|
+
try:
|
|
18
|
+
result = subprocess.run([*shlex.split(editor), path])
|
|
19
|
+
if result.returncode != 0:
|
|
20
|
+
raise CliError(f"Editor exited with {result.returncode}; not syncing")
|
|
21
|
+
return Path(path).read_text()
|
|
22
|
+
finally:
|
|
23
|
+
os.unlink(path)
|
pebbenote_cli/errors.py
ADDED
pebbenote_cli/http.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import urllib.error
|
|
3
|
+
import urllib.parse
|
|
4
|
+
import urllib.request
|
|
5
|
+
|
|
6
|
+
from pebbenote_cli.errors import CliError
|
|
7
|
+
|
|
8
|
+
USER_AGENT = "pebbenote-cli"
|
|
9
|
+
|
|
10
|
+
# What the reverse proxy answers with when Keycloak and the backend are down
|
|
11
|
+
UNAVAILABLE_STATUSES = {502, 503, 504}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def request(method, url, *, data=None, form=None, token=None):
|
|
15
|
+
headers = {"User-Agent": USER_AGENT}
|
|
16
|
+
body = None
|
|
17
|
+
if form is not None:
|
|
18
|
+
body = urllib.parse.urlencode(form).encode()
|
|
19
|
+
headers["Content-Type"] = "application/x-www-form-urlencoded"
|
|
20
|
+
elif data is not None:
|
|
21
|
+
body = json.dumps(data).encode()
|
|
22
|
+
headers["Content-Type"] = "application/json"
|
|
23
|
+
if token:
|
|
24
|
+
headers["Authorization"] = f"Bearer {token}"
|
|
25
|
+
req = urllib.request.Request(url, data=body, headers=headers, method=method)
|
|
26
|
+
try:
|
|
27
|
+
with urllib.request.urlopen(req) as response:
|
|
28
|
+
return response.status, json.loads(response.read() or "null")
|
|
29
|
+
except urllib.error.HTTPError as e:
|
|
30
|
+
try:
|
|
31
|
+
payload = json.loads(e.read() or "null")
|
|
32
|
+
except ValueError:
|
|
33
|
+
payload = None
|
|
34
|
+
return e.code, payload
|
|
35
|
+
except urllib.error.URLError as e:
|
|
36
|
+
raise CliError(f"Cannot reach {url}: {e.reason}") from e
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""Standing instructions as a Markdown bullet list, one instruction per item."""
|
|
2
|
+
|
|
3
|
+
BULLETS = ("- ", "* ")
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def format_instructions(instructions: list[str]) -> str:
|
|
7
|
+
return "".join(f"- {instruction}\n" for instruction in instructions)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def parse_instructions(text: str) -> list[str]:
|
|
11
|
+
instructions: list[str] = []
|
|
12
|
+
for line in text.splitlines():
|
|
13
|
+
line = line.strip()
|
|
14
|
+
if line in ("-", "*"):
|
|
15
|
+
# An empty bullet, the lines after it start no instruction of its own
|
|
16
|
+
instructions.append("")
|
|
17
|
+
elif line.startswith(BULLETS):
|
|
18
|
+
instructions.append(line[2:].strip())
|
|
19
|
+
elif line and instructions:
|
|
20
|
+
# Continuation of a wrapped instruction
|
|
21
|
+
instructions[-1] = f"{instructions[-1]} {line}".strip()
|
|
22
|
+
elif line:
|
|
23
|
+
instructions.append(line)
|
|
24
|
+
return [instruction for instruction in instructions if instruction]
|
pebbenote_cli/merge.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""A three way merge of text by lines, with git style conflict markers."""
|
|
2
|
+
|
|
3
|
+
from difflib import SequenceMatcher
|
|
4
|
+
|
|
5
|
+
YOURS_MARKER = "<<<<<<< yours"
|
|
6
|
+
SEPARATOR = "======="
|
|
7
|
+
SERVER_MARKER = ">>>>>>> server"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _sync_regions(base: list[str], mine: list[str], theirs: list[str]):
|
|
11
|
+
"""
|
|
12
|
+
The stretches of base that both sides kept, as (base start, base end,
|
|
13
|
+
mine start, theirs start). Ends with an empty one after the last line.
|
|
14
|
+
"""
|
|
15
|
+
mine_blocks = SequenceMatcher(None, base, mine, autojunk=False)
|
|
16
|
+
theirs_blocks = SequenceMatcher(None, base, theirs, autojunk=False)
|
|
17
|
+
mine_matches = mine_blocks.get_matching_blocks()
|
|
18
|
+
theirs_matches = theirs_blocks.get_matching_blocks()
|
|
19
|
+
|
|
20
|
+
i = j = 0
|
|
21
|
+
while i < len(mine_matches) and j < len(theirs_matches):
|
|
22
|
+
mine_base, mine_start, mine_size = mine_matches[i]
|
|
23
|
+
theirs_base, theirs_start, theirs_size = theirs_matches[j]
|
|
24
|
+
start = max(mine_base, theirs_base)
|
|
25
|
+
end = min(mine_base + mine_size, theirs_base + theirs_size)
|
|
26
|
+
if start < end:
|
|
27
|
+
yield (
|
|
28
|
+
start,
|
|
29
|
+
end,
|
|
30
|
+
mine_start + start - mine_base,
|
|
31
|
+
theirs_start + start - theirs_base,
|
|
32
|
+
)
|
|
33
|
+
if mine_base + mine_size < theirs_base + theirs_size:
|
|
34
|
+
i += 1
|
|
35
|
+
else:
|
|
36
|
+
j += 1
|
|
37
|
+
yield len(base), len(base), len(mine), len(theirs)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def merge3(base: str, mine: str, theirs: str) -> tuple[str, bool]:
|
|
41
|
+
"""
|
|
42
|
+
Merges the changes from base to mine with the ones from base to theirs.
|
|
43
|
+
Returns the merged text and whether it has conflicts: places both sides
|
|
44
|
+
changed differently, kept as both versions between conflict markers.
|
|
45
|
+
"""
|
|
46
|
+
base_lines, mine_lines, theirs_lines = (
|
|
47
|
+
text.splitlines() for text in (base, mine, theirs)
|
|
48
|
+
)
|
|
49
|
+
merged: list[str] = []
|
|
50
|
+
has_conflicts = False
|
|
51
|
+
base_at = mine_at = theirs_at = 0
|
|
52
|
+
|
|
53
|
+
for start, end, mine_start, theirs_start in _sync_regions(
|
|
54
|
+
base_lines, mine_lines, theirs_lines
|
|
55
|
+
):
|
|
56
|
+
base_chunk = base_lines[base_at:start]
|
|
57
|
+
mine_chunk = mine_lines[mine_at:mine_start]
|
|
58
|
+
theirs_chunk = theirs_lines[theirs_at:theirs_start]
|
|
59
|
+
|
|
60
|
+
if mine_chunk == theirs_chunk or theirs_chunk == base_chunk:
|
|
61
|
+
merged += mine_chunk
|
|
62
|
+
elif mine_chunk == base_chunk:
|
|
63
|
+
merged += theirs_chunk
|
|
64
|
+
else:
|
|
65
|
+
has_conflicts = True
|
|
66
|
+
merged += [YOURS_MARKER, *mine_chunk, SEPARATOR, *theirs_chunk]
|
|
67
|
+
merged.append(SERVER_MARKER)
|
|
68
|
+
|
|
69
|
+
merged += base_lines[start:end]
|
|
70
|
+
base_at = end
|
|
71
|
+
mine_at = mine_start + end - start
|
|
72
|
+
theirs_at = theirs_start + end - start
|
|
73
|
+
|
|
74
|
+
return "".join(f"{line}\n" for line in merged), has_conflicts
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def has_markers(text: str) -> bool:
|
|
78
|
+
"""Whether conflicts of merge3 are left in the text"""
|
|
79
|
+
return any(line in (YOURS_MARKER, SERVER_MARKER) for line in text.splitlines())
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pebbenote-cli
|
|
3
|
+
Version: 0.6.1
|
|
4
|
+
Summary: Command line client for pebbenote
|
|
5
|
+
License: AGPL-3.0-only
|
|
6
|
+
Keywords: pebble,notes,cli
|
|
7
|
+
Author: Grzegorz Koperwas
|
|
8
|
+
Author-email: admin@grzegorzkoperwas.site
|
|
9
|
+
Requires-Python: >=3.13,<4.0
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
16
|
+
Classifier: Topic :: Text Editors
|
|
17
|
+
Classifier: Topic :: Utilities
|
|
18
|
+
Requires-Dist: argcomplete (>=3.7.2,<4.0.0)
|
|
19
|
+
Requires-Dist: attrs (>=26.1.0,<27.0.0)
|
|
20
|
+
Requires-Dist: httpx (>=0.28.1,<0.29.0)
|
|
21
|
+
Project-URL: Homepage, https://github.com/HakierGrzonzo/pebbenote
|
|
22
|
+
Project-URL: Repository, https://github.com/HakierGrzonzo/pebbenote
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# Pebbenote CLI
|
|
26
|
+
|
|
27
|
+
Opens a note in `$EDITOR` and syncs it with the backend when the editor quits. Python 3.13+, packaged with Poetry. Talks to the backend through a client generated from its OpenAPI schema.
|
|
28
|
+
|
|
29
|
+
## Install
|
|
30
|
+
|
|
31
|
+
From PyPI, as a shell command available everywhere:
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
pipx install pebbenote-cli # `pipx upgrade pebbenote-cli` to update
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
From a checkout (builds with Poetry's backend):
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pipx install ./cli # from the repo root; use `pipx install --force ./cli` to update
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
For development, install into the project virtualenv and prefix commands with `poetry run`:
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
cd cli
|
|
47
|
+
poetry install
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Usage
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
pebbenote # edit the default note
|
|
54
|
+
pebbenote <note_id> # edit a specific note
|
|
55
|
+
pebbenote list # list notes (* = default)
|
|
56
|
+
pebbenote delete [id] # delete a note (default note without an id; -y skips the prompt)
|
|
57
|
+
pebbenote share [id] # print a link to view a note (default note without an id)
|
|
58
|
+
pebbenote instructions # edit the standing instructions as a list
|
|
59
|
+
pebbenote action <text> # ask the assistant to change the default note (--note <id> for another)
|
|
60
|
+
pebbenote login # force a new login
|
|
61
|
+
pebbenote completion <shell> # print the completion script for bash, zsh or fish
|
|
62
|
+
pebbenote > note.md # piped output prints the note instead of opening the editor
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`pebbenote instructions` opens the standing instructions (the ones the assistant follows on every note) as a list, one `- ` item each. Add, reword or delete items; the saved list replaces the stored one, and the backend then applies it in the background to every note. `--no-apply` only saves the list. Piped, it prints the list.
|
|
66
|
+
|
|
67
|
+
`pebbenote delete <id>` shows the note's first line and asks before deleting it. Deleting the default note makes the oldest remaining note the default. Without a terminal to ask on it needs `--yes`.
|
|
68
|
+
|
|
69
|
+
`pebbenote share` prints a link to view the note in a browser, without an account. Anyone with the link sees the note as it is when they open it, until the link expires (after 7 days, unless the backend is set up differently) or the note is deleted. A link can't be cancelled on its own. Only the link goes to stdout, so `pebbenote share | wl-copy` copies it.
|
|
70
|
+
|
|
71
|
+
`pebbenote action add oat milk` sends the action to the assistant and prints the updated note. If the assistant takes longer than the backend waits, the CLI says so and quits; the note is updated in the background.
|
|
72
|
+
|
|
73
|
+
### Shell completion
|
|
74
|
+
|
|
75
|
+
Commands, options and note ids complete on Tab once the script is loaded:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
pebbenote completion fish > ~/.config/fish/completions/pebbenote.fish
|
|
79
|
+
eval "$(pebbenote completion bash)" # in ~/.bashrc
|
|
80
|
+
eval "$(pebbenote completion zsh)" # in ~/.zshrc, after compinit
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Note ids are fetched from the backend with each note's first line as description (fish and zsh show it). That needs a login (`pebbenote login`): completion never starts one, when logged out or offline it only offers `default`.
|
|
84
|
+
|
|
85
|
+
### Conflicts
|
|
86
|
+
|
|
87
|
+
An edit is sent with the version it was made on. When the note or the instructions were changed elsewhere while the editor was open (on the watch, by the assistant, in another terminal), the backend refuses the edit and the CLI merges both like git: changes in different places are combined and synced without asking, changes to the same lines reopen the editor with both versions between markers:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
<<<<<<< yours
|
|
91
|
+
- oat milk
|
|
92
|
+
=======
|
|
93
|
+
- soy milk
|
|
94
|
+
>>>>>>> server
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Edit that into what you want and quit. If markers are still there, nothing is synced and the text is kept in `$XDG_STATE_HOME/pebbenote/unresolved.md`.
|
|
98
|
+
|
|
99
|
+
## Configuration
|
|
100
|
+
|
|
101
|
+
On first run `$XDG_CONFIG_HOME/pebbenote/config.toml` (default `~/.config/pebbenote/config.toml`) is created with the production URLs:
|
|
102
|
+
|
|
103
|
+
```toml
|
|
104
|
+
backend_url = "https://dev.grzegorzkoperwas.site"
|
|
105
|
+
issuer = "https://auth.grzegorzkoperwas.site/realms/pebbenote"
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Edit it to point at another backend, e.g. `http://localhost:8000` and `http://localhost:8080/realms/pebbenote` for local development. The editor comes from `$EDITOR`, then `$VISUAL`, then `vi`.
|
|
109
|
+
|
|
110
|
+
Login uses the Keycloak device flow. Tokens are stored in `$XDG_STATE_HOME/pebbenote/tokens.json` (default `~/.local/state/pebbenote/tokens.json`).
|
|
111
|
+
|
|
112
|
+
## Regenerating the API client
|
|
113
|
+
|
|
114
|
+
`pebbenote_cli/client/` is generated with [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) from a locally running backend (`ENVIRONMENT=local`, which serves `/openapi.json`). Don't edit it by hand; after changing the backend API run:
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
./generate_client.sh # uses http://localhost:8000/openapi.json, override with OPENAPI_URL
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Releasing
|
|
121
|
+
|
|
122
|
+
Bump `version` in `pyproject.toml` and merge it, then tag that commit:
|
|
123
|
+
|
|
124
|
+
```sh
|
|
125
|
+
git tag cli-v0.6.1 && git push origin cli-v0.6.1
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
The `Publish CLI` workflow checks the tag matches the version, builds and uploads to PyPI with trusted publishing (no token in the repo).
|
|
129
|
+
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
pebbenote_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
pebbenote_cli/__main__.py,sha256=SW-74PCGQT9hxbkXUVukhlBtaFGMy4ERmSLeH1dt0yo,43
|
|
3
|
+
pebbenote_cli/api.py,sha256=ezNi0kq1zsssBQH3JrL3z9HsDrk0RZtEKweYkJF2pNs,2194
|
|
4
|
+
pebbenote_cli/auth.py,sha256=SU1La92-G310owR2zYiCqXO1yls1zHdExfy8U-1LTas,3945
|
|
5
|
+
pebbenote_cli/cli.py,sha256=P-as5PR1D9lZHbm9ZShqc4PU43Q_tVYFMB9g8qiDyz4,9736
|
|
6
|
+
pebbenote_cli/client/__init__.py,sha256=E_1VaAVOxpnmTYiQTwshJMCDMJc5LsmtqYl87kW2ufM,152
|
|
7
|
+
pebbenote_cli/client/api/__init__.py,sha256=zTSiG_ujSjAqWPyc435YXaX9XTlpMjiJWBbV-f-YtdA,45
|
|
8
|
+
pebbenote_cli/client/api/actions/__init__.py,sha256=5vd9uJWAjRqa9xzxzYkLD1yoZ12Ld_bAaNB5WX4fbE8,56
|
|
9
|
+
pebbenote_cli/client/api/actions/apply_action.py,sha256=1ID4MURQ7cra1SFWzf0XAK5m5n2Ku-X5ijZkU9FwhGE,4243
|
|
10
|
+
pebbenote_cli/client/api/instructions/__init__.py,sha256=5vd9uJWAjRqa9xzxzYkLD1yoZ12Ld_bAaNB5WX4fbE8,56
|
|
11
|
+
pebbenote_cli/client/api/instructions/list_instructions.py,sha256=97SF8znAWKZO2E-FeK3Gg0NjYSTru-J8AFhMHRiBkZI,3204
|
|
12
|
+
pebbenote_cli/client/api/instructions/replace_instructions.py,sha256=vmFv3k7osuw1CS-_InphZkECTJXmnNEhI92FPKsZvkY,6026
|
|
13
|
+
pebbenote_cli/client/api/notes/__init__.py,sha256=5vd9uJWAjRqa9xzxzYkLD1yoZ12Ld_bAaNB5WX4fbE8,56
|
|
14
|
+
pebbenote_cli/client/api/notes/create_note.py,sha256=N8E5pqXq4Kua1i3yKleHXrNOXAys-wV9JfdzqC6IOv0,4205
|
|
15
|
+
pebbenote_cli/client/api/notes/delete_note.py,sha256=lnrvum8UDKFjXYqN9t4tCylfIzulYafa0lsAxZ5qHRs,3853
|
|
16
|
+
pebbenote_cli/client/api/notes/edit_note_by_id.py,sha256=qLSVAoLXosRTO5ZrxtlM0QnOMnBy3-IIjD0Kai2009U,5340
|
|
17
|
+
pebbenote_cli/client/api/notes/get_note_by_id.py,sha256=WVd58mE18hzCHs_n8Dsdp20pKgmTlSNrzcfQ3g-XdaE,5227
|
|
18
|
+
pebbenote_cli/client/api/notes/list_notes.py,sha256=YQr3IcAGpFPNYGGkt1mEquHaXI394VvtXOCHJeRHSfs,3312
|
|
19
|
+
pebbenote_cli/client/api/notes/set_default_note.py,sha256=z9OeCBNfWqT5bk8_1rgOTG7iXuMuYZOTkTgpow8m158,3997
|
|
20
|
+
pebbenote_cli/client/api/sharing/__init__.py,sha256=5vd9uJWAjRqa9xzxzYkLD1yoZ12Ld_bAaNB5WX4fbE8,56
|
|
21
|
+
pebbenote_cli/client/api/sharing/get_note_sharing.py,sha256=bdxBFahhLZHS9Nnw8oL8JQEa-L3eAQGCYzUCqBVl8Rw,4285
|
|
22
|
+
pebbenote_cli/client/api/sharing/get_shared_note.py,sha256=Kz2Nb3M1fNva1N95dHtYLg85unZUHHT4Qnw5rTITRAU,4409
|
|
23
|
+
pebbenote_cli/client/api/sharing/join_shared_note.py,sha256=ZdKeiK9JemsKOt5rxTPGIIVOCfPlW3bR5WwgiCqPNaA,4680
|
|
24
|
+
pebbenote_cli/client/api/sharing/make_note_private.py,sha256=yC3eMriHWzxx2z056YNmBll4GgJ_fNeDFwMHPMpv8c0,4329
|
|
25
|
+
pebbenote_cli/client/api/sharing/remove_note_member.py,sha256=SjFPXLmHTOrnCq3ajCDtF3qzqQP1UCMHCJFjeB9rU2Y,4581
|
|
26
|
+
pebbenote_cli/client/api/sharing/revoke_share_link.py,sha256=fWa1Kcq05iqIrCX3w2qewan6qLLcpFI3asokj9t32o0,4824
|
|
27
|
+
pebbenote_cli/client/api/sharing/share_note.py,sha256=gHqxJ1wJ-KRdWB4v6tzUG_s_KZadB_fULpN8y-KFV7U,5801
|
|
28
|
+
pebbenote_cli/client/client.py,sha256=5TZkF0JpMHgvYykROEpjaNDGbSchq33uZCh-GaH8_WU,12426
|
|
29
|
+
pebbenote_cli/client/errors.py,sha256=gO8GBmKqmSNgAg-E5oT-oOyxztvp7V_6XG7OUTT15q0,546
|
|
30
|
+
pebbenote_cli/client/models/__init__.py,sha256=vntVATHc4hlmE689E3QBDjQmF5dG5XtE9xfY43YcqcE,1573
|
|
31
|
+
pebbenote_cli/client/models/action_accepted_model.py,sha256=Y2bcrdrX-xTZ51X3LvoIJrKEE89Xrpe0NwaHab02JGQ,1800
|
|
32
|
+
pebbenote_cli/client/models/action_edit_model.py,sha256=o3QXkw7QeJ55AY5tT0IgXDIlKXs4IjIe6wvOyk7SKMs,2577
|
|
33
|
+
pebbenote_cli/client/models/action_model.py,sha256=le7SiCoCSrnrSloyFsoUgLonbQ7alB3y-8GYmq0fe4Q,2775
|
|
34
|
+
pebbenote_cli/client/models/action_status.py,sha256=1wVxjSPaQ_VyX-X8vQPiVLsRXN_qOdlQP6f72xG3G5c,182
|
|
35
|
+
pebbenote_cli/client/models/http_validation_error.py,sha256=kCljaE8f9FCb5n7GKcsRSVmMyh3qOIn9Ps84ZpawRNM,2334
|
|
36
|
+
pebbenote_cli/client/models/instructions_conflict_model.py,sha256=i2MJ_48o7YdS9oc_9aItep-PwJLVWK6Egwg3AdNZ6gA,1987
|
|
37
|
+
pebbenote_cli/client/models/instructions_edit_model.py,sha256=PWLh68JAJPApFsS2wl3iMA49udRiBQbBuayTIP3Uswc,1864
|
|
38
|
+
pebbenote_cli/client/models/instructions_model.py,sha256=_qvjGOuvDcpuIVOQHAvk2U5nkeV1uiR5Eu0-XsXzjb0,1791
|
|
39
|
+
pebbenote_cli/client/models/note_access.py,sha256=RKdCGvHbm6HAXIWxkJn-dimS7U4GmHIk-Lz5JH_0Ats,174
|
|
40
|
+
pebbenote_cli/client/models/note_conflict_model.py,sha256=BRBRZhMD8yStCzA42Kx-e9snLlwUmvW4LXJNHWaW8tg,1891
|
|
41
|
+
pebbenote_cli/client/models/note_member_model.py,sha256=ZLRu6dn12Ou_2jLUbb-cNzs1TMRhv2azGgkEF7gF2Tg,2417
|
|
42
|
+
pebbenote_cli/client/models/note_model.py,sha256=YX7v7gnrB0yPU9mqyJzZDUx_pySoDun99dIiARdKf7w,2797
|
|
43
|
+
pebbenote_cli/client/models/note_sharing_model.py,sha256=i4gzaswvD1FZL_d5Xl4OU15UB3-s-DSRC5yFly8cNM8,2719
|
|
44
|
+
pebbenote_cli/client/models/note_update_model.py,sha256=qUxS2x0_MSatqgehZ3Rqstn8RYUAhfhGbSYihfRElHI,2287
|
|
45
|
+
pebbenote_cli/client/models/note_view_model.py,sha256=RkAXOx2aN80Z5LiXSEDzOMQR059lLnhAAxqMK1ZdyYk,3719
|
|
46
|
+
pebbenote_cli/client/models/share_access.py,sha256=8jLtEoDmQS8aOsGnlibuuqdkzvTqpYVgHx52QM4qSKY,155
|
|
47
|
+
pebbenote_cli/client/models/share_create_model.py,sha256=6ALirqNcy_5ignMuZ0dBW3G3UMw4AWpxslfjzZDI3yk,1905
|
|
48
|
+
pebbenote_cli/client/models/share_link_model.py,sha256=wwkR4dw1Ask3hniGO3mbE5gi4rWMQ7LKTiX7ras2iFI,3502
|
|
49
|
+
pebbenote_cli/client/models/shared_note_model.py,sha256=wSmoVmm50IVUuOCaTwgHlc6A3uzH32LCaWq-V-9Ds5Y,2260
|
|
50
|
+
pebbenote_cli/client/models/validation_error.py,sha256=MfubWpf-9-4Jj7pYNufJcgCe5-JM0giNhiv_eTkGGBA,3191
|
|
51
|
+
pebbenote_cli/client/models/validation_error_context.py,sha256=XgIl3xaw1DhhBFRyQykxQLDV5nSCo0zQ9_IpPmoU6kA,1281
|
|
52
|
+
pebbenote_cli/client/types.py,sha256=0We4NPvhIYASRpQ3le41nmJeEAVm42-2VKdzlJ4Ogok,1343
|
|
53
|
+
pebbenote_cli/config.py,sha256=l7QfisPjus2nPz10axeDBwae-oJ7yddSzm6inbR6BnI,1497
|
|
54
|
+
pebbenote_cli/editor.py,sha256=NzspUERRp2MppZZx-ZgUrqRfyAf1sn0VnddvDwidQ0c,641
|
|
55
|
+
pebbenote_cli/errors.py,sha256=E7j5p5YgtOqs6khD1wLSH9MBbUFhA7rkCZ0ypOxUgL8,273
|
|
56
|
+
pebbenote_cli/http.py,sha256=6uzMrehywC3fYcevNIf22FeqMETZM89eX1N0LNsTUUc,1235
|
|
57
|
+
pebbenote_cli/instructions.py,sha256=H8OZ1yW1YQ7kxJxnaOe9AzwLt8fuxGKPdeDQsbPdyYE,906
|
|
58
|
+
pebbenote_cli/merge.py,sha256=NMGsyyRnB0ZaQBNn75BrmtovWol3VkvGM9FgPnwHzjc,2901
|
|
59
|
+
pebbenote_cli-0.6.1.dist-info/METADATA,sha256=p1ESwoLtH9-qYpci7fRMBzh79kUhVaiWr6a53fvOI8k,5852
|
|
60
|
+
pebbenote_cli-0.6.1.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
|
|
61
|
+
pebbenote_cli-0.6.1.dist-info/entry_points.txt,sha256=o0F2HrWjaTFyOLUG8_6tvsh04UrkNefNL_Yrse2A1MQ,52
|
|
62
|
+
pebbenote_cli-0.6.1.dist-info/RECORD,,
|