Python Forum
Advanced CLI Snippet Manager - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: Code sharing (https://python-forum.io/forum-5.html)
+--- Thread: Advanced CLI Snippet Manager (/thread-29765.html)



Advanced CLI Snippet Manager - bytebutcher - Sep-18-2020

I made a cli tool for managing snippets. The source code can be found at https://github.com/bytebutcher/snippet.

If you have any suggestions regarding code-quality, features or any other kind of feedback i'm happy to hear from you guys!

Output:
# Add a new snippet to the database $ snippet -e archive/extract-tgz -f 'tar -xzvf <archive>' # Edit a snippet (will open vim) $ snippet -e archive/extract-tgz # Search a snippet which include the term "extract" (will open fzf) $ snippet -t extract # Fill snippet with a value $ snippet -t archive/extract-tgz /path/to/foo.tar.gz tar -xvf /path/to/foo.tar.gz # Fill snippet with multiple values $ snippet -t archive/extract-tgz /path/to/foo.tar.gz /path/to/bar.tar.gz tar -xvf /path/to/foo.tar.gz tar -xvf /path/to/bar.tar.gz # Fill snippet with multiple values while using repeatable placeholders (e.g. <file...>) $ snippet -f "tar -czvf <archive> <file...>" /path/to/foo.tar file=foo bar tar -czvf /path/to/foo.tar.gz foo bar # Using preset '<datetime>' to include current datetime $ snippet -f "tar -czvf '<datetime>.tar.gz' <file...>" file=foo bar tar -czvf 20770413000000.tar.gz foo bar # Import values from file $ cat <<EOF > files.txt foo bar EOF $ snippet -f "tar -czvf '<datetime>.tar.gz' <file...>" file:files.txt tar -czvf 20770413000000.tar.gz foo bar # Using optionals $ snippet -f "python3 -m http.server[ --bind<lhost>][ <lport>]" python3 -m http.server $ snippet -f "python3 -m http.server[ --bind<lhost>][ <lport>]" lport=4444 python3 -m http.server 4444 # Using defaults $ snippet -f "python3 -m http.server[ --bind<lhost>] <lport=8000>" python3 -m http.server 8000 # Using codecs $ snippet -f "tar -czvf <archive:squote> <file:squote...>" /path/to/foo.tar file=foo bar tar -czvf '/path/to/foo.tar.gz' 'foo' 'bar'



RE: Advanced CLI Snippet Manager - bytebutcher - Sep-20-2020

Thanks for your reply. Since the application contains over 1000 lines of code i just linked to the repo. Hope this is fine with you guys!