Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- encoding: utf-8 -*-
- """
- Note = id + content + tags + created + modified + public_url
- Share a note = publish to gist.
- Public need github account
- """
- import json
- import os.path
- import click
- RC_FILES = [
- './.zetanoterc',
- '~/.zetanoterc',
- '/usr/local/etc/zetanote/zetanoterc',
- '/etc/zetanote/zenoterc',
- ]
- def read_rc():
- """Resolve one RC file and parse it.
- RC file must be in JSON format.
- The order of search files are:
- * `./.zetanoterc`
- * `~/.zetanoterc`
- * '/usr/local/etc/zetanote/zetanoterc`
- * `/etc/zetanote/zenoterc`
- """
- for rc_file in RC_FILES:
- if os.path.exists(rc_file):
- with open(rc_file) as f:
- return json.load(f)
- return {}
- @click.group()
- @click.pass_context
- def zetanote(ctx):
- """Zetanote - Organizing notes in less pain."""
- ctx.RC = read_rc()
- @zetanote.command()
- @click.pass_context
- def ls(ctx):
- """List all notes."""
- pass
- @zetanote.command()
- @click.pass_context
- def rm(ctx):
- """Remove notes."""
- @zetanote.command()
- @click.pass_context
- def tree(ctx):
- """List notes as tree.
- Example Output::
- .
- ├── DeicW | Hello World
- | ├── EckwA | Sub Page 1
- | ├── EciWL | Sub Page 2
- ...
- """
- @zetanote.command()
- @click.pass_context
- def add(ctx):
- """Create a new note from input, and then output the link.
- This link is similar to `zetanote://XdoaQ`
- """
- @zetanote.command()
- @click.pass_context
- def edit(ctx):
- """Edit an existing note."""
- @zetanote.command()
- @click.pass_context
- def open(ctx):
- """Open a note in $EDITOR, and create it if note doesn't exist.
- """
- if __name__ == '__main__':
- zetanote()
Add Comment
Please, Sign In to add comment