monitor mode is may be broken
derVedro opened this issue · 2 comments
If I try something like: $ mdv -M "notes:md::open '__fp__'"
I get a KeyError:
`Traceback (most recent call last):
File "/home/me/.local/bin/mdv", line 8, in <module>
sys.exit(run())
File "/home/me/.local/lib/python3.8/site-packages/mdv/markdownviewer.py", line 1655, in run
monitor_dir(kw)
File "/home/me/.local/lib/python3.8/site-packages/mdv/markdownviewer.py", line 1519, in monitor_dir
args.pop("monitor_file")
KeyError: 'monitor_file'
May be I am doing something wrong cause I missunderstud the -M option.
Thank you for the fix, but it's possible that something else is broken too.
First let me explain, what I am doing and then how. So may be I am doing something wrong and that's the issue. I have a directory notes with some markdown files. I edit them and I want to render them instantly in some terminal window as I save them. So I use that -M option. I don't really understand the command syntax, so far as I get it from the code and readme, it's something like "PATH : EXTENSIONS :: COMMAND 'MAGIC_PLACEHOLDER'".
Now the issue, If I run the latest version mdv with your fix (I just replaced the mdv directory of the pip installed version with github code), I still get trouble. So let assume I have two simple md files in /tmp/notes - first.md and second.md, and I run mdv like that:
$ mdv -M "/tmp/notes:md::open '__fp__'"
SOME HEADER FROM SECOND.MD
(/tmp/notes/second.md)
Running open '_"/tmp/notes/second.md"_'
Traceback (most recent call last):
File "/home/me/.local/bin/mdv", line 8, in <module>
sys.exit(run())
File "/home/me/.local/lib/python3.8/site-packages/mdv/markdownviewer.py", line 1674, in run
monitor_dir(kw)
File "/home/me/.local/lib/python3.8/site-packages/mdv/markdownviewer.py", line 1600, in monitor_dir
show_fp(fp)
File "/home/me/.local/lib/python3.8/site-packages/mdv/markdownviewer.py", line 1529, in show_fp
run_changed_file_cmd(cmd, fp=fp, pretty=pretty)
File "/home/me/.local/lib/python3.8/site-packages/mdv/markdownviewer.py", line 1512, in run_changed_file_cmd
cmd = cmd.replace(r, what.encode("base64"))
LookupError: 'base64' is not a text encoding; use codecs.encode() to handle arbitrary codecs