add ability to add/remove tags
This commit is contained in:
parent
0750e9e333
commit
1e6151a5f4
@ -1,2 +1,3 @@
|
||||
from .z import *
|
||||
from .create import *
|
||||
from .tags import *
|
||||
|
12
src/z/tags.py
Normal file
12
src/z/tags.py
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
def remove_tags(name:str):
|
||||
curr_tags = name.split("__")[-1].split(".")[0].split("_")
|
||||
print(curr_tags)
|
||||
|
||||
|
||||
def main(args):
|
||||
remove_tags(args.file)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main(None)
|
13
src/z/z.py
13
src/z/z.py
@ -1,23 +1,32 @@
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
from z import create
|
||||
from z import create, tags
|
||||
import sys
|
||||
|
||||
def init_parser():
|
||||
parser = argparse.ArgumentParser(prog="z.py", description="top level prog")
|
||||
sub_parsers = parser.add_subparsers(help="subcommand help")
|
||||
|
||||
create_parser = sub_parsers.add_parser("create", help="create note")
|
||||
create_parser.set_defaults(func=create.main)
|
||||
create_parser.add_argument("name", help="name of note to create")
|
||||
create_parser.add_argument("-t", "--tags", nargs="?", default="", const="", help="comma seperated list of tags for note")
|
||||
create_parser.add_argument("-s", "--silo", nargs="?", default="", const="", help="Optionally create note in silo")
|
||||
|
||||
tags_parser = sub_parsers.add_parser("tags", help="edit tags")
|
||||
tags_parser.set_defaults(func=tags.main)
|
||||
tags_parser.add_argument("file", help="name of file to create")
|
||||
|
||||
return parser
|
||||
|
||||
def main():
|
||||
z_file = Path("./.z")
|
||||
if not z_file.is_file():
|
||||
raise Exception("You aren't in a z.py folder. Re-run in a z.py folder")
|
||||
raise Exception("You aren't in a z-py folder! Re-run in a z.py folder")
|
||||
parser = init_parser()
|
||||
if len(sys.argv) == 1:
|
||||
parser.print_help(sys.stderr)
|
||||
sys.exit(1)
|
||||
args = parser.parse_args()
|
||||
args.func(args)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user