diff options
| author | Loic Guegan <loic.guegan@mailbox.org> | 2024-04-19 14:26:58 +0200 |
|---|---|---|
| committer | Loic Guegan <loic.guegan@mailbox.org> | 2024-04-19 14:26:58 +0200 |
| commit | fd45b611986fdd36243099e6801b429eef75c2ca (patch) | |
| tree | 9d0158292536a86ea87f637576fc7c4dce23f714 | |
| parent | ab5c2a08c793decc450d2c2803008f0f3c43791b (diff) | |
Improve pnote API
| -rw-r--r-- | README.md | 15 | ||||
| -rw-r--r-- | pnote/__init__.py | 2 | ||||
| -rw-r--r-- | pnote/__main__.py | 10 |
3 files changed, 17 insertions, 10 deletions
@@ -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*: diff --git a/pnote/__init__.py b/pnote/__init__.py index e4dd2d5..7f44083 100644 --- a/pnote/__init__.py +++ b/pnote/__init__.py @@ -1,3 +1,3 @@ -__version__ = "0.0.26" +__version__ = "0.0.27" from pnote.__main__ import main diff --git a/pnote/__main__.py b/pnote/__main__.py index d652ddd..c5c2ede 100644 --- a/pnote/__main__.py +++ b/pnote/__main__.py @@ -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": |
