46 lines
938 B
Python
Executable File
46 lines
938 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import textwrap
|
|
import argparse
|
|
import subprocess
|
|
|
|
from datetime import date
|
|
|
|
def load_args():
|
|
"""loads cli parameters"""
|
|
parser = argparse.ArgumentParser(
|
|
description="Takes a snapshot of all pad contents"
|
|
)
|
|
parser.add_argument('all', nargs=argparse.REMAINDER)
|
|
args = parser.parse_args()
|
|
return vars(args)
|
|
|
|
|
|
|
|
def main():
|
|
args = load_args()
|
|
name = ' '.join(args['all'])
|
|
today = date.today().strftime('%Y-%m-%d')
|
|
filename = f'/home/bredow/nextcloud/perso/notes/zettelkasten/inbox/{name}.md'
|
|
|
|
content = textwrap.dedent(f"""\
|
|
---
|
|
date: {today}
|
|
tags:
|
|
-
|
|
---
|
|
|
|
""")
|
|
|
|
if not os.path.exists(filename):
|
|
with open(filename, 'w') as file:
|
|
file.write(content)
|
|
|
|
subprocess.run(['nvim', '+normal G$', '+startinsert', filename])
|
|
os._exit(0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|