Improve pnote API

This commit is contained in:
Loïc Guégan 2024-04-19 14:26:58 +02:00
parent ab5c2a08c7
commit fd45b61198
3 changed files with 17 additions and 10 deletions

View file

@ -13,36 +13,37 @@ Installation:
Create a new project:
```
> pnote ~/mynotes
> pnote -d ~/mynotes
> # See configuration in ~/mynotes/config.json
> # If -d not specified, ${HOME}/.pnote will be used
```
Open and edit today's note file:
```
> pnote ~/mynotes -t
> pnote -d ~/mynotes -t
```
## Features
Search for files:
```
> pnote ~/mynotes search -h
> pnote -d ~/mynotes search -h
```
Tag files:
```
> pnote ~/mynotes tag -h
> pnote -d ~/mynotes tag -h
```
Manage your project:
```
> pnote ~/mynotes admin -h
> pnote -d ~/mynotes admin -h
```
Export your notes:
```
> pnote ~/mynotes search --subpath | pnote ~/mynotes export --json
> pnote ~/mynotes search --subpath | pnote ~/mynotes export --template template.txt
> pnote -d ~/mynotes search --subpath | pnote -d ~/mynotes export --json
> pnote -d ~/mynotes search --subpath | pnote -d ~/mynotes export --template template.txt
```
For more information on *pnote*:

View file

@ -1,3 +1,3 @@
__version__ = "0.0.26"
__version__ = "0.0.27"
from pnote.__main__ import main

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python
import os, argparse
from pathlib import Path
from pnote.project import *
from pnote.tools import *
from pnote import __version__
@ -11,9 +12,9 @@ def main():
prog='PNote',
description='Note management tool',
epilog='pnote v'+__version__)
parser.add_argument('path', help="Path to a pnote project")
parser.add_argument('-t', '--today', help="Open today's note file", action="store_true")
parser.add_argument('-o', '--open', help="Open specific note file")
parser.add_argument('-d', '--dir', help="Project directory")
subparsers = parser.add_subparsers(dest="tool", help='Tool to use')
# Tools
@ -30,7 +31,12 @@ def main():
args = parser.parse_args()
## Load project
project=Project(args.path)
if args.dir:
project=Project(args.dir)
else:
pdir=Path.home()/".pnote/"
pdir.mkdir(parents=True, exist_ok=True)
project=Project(pdir)
## Run tool
if args.tool == "search":