Esempio n. 1
0
File: cli.py Progetto: Camr0n/ark
def cmd_edit(parser):
    if not site.home():
        sys.exit("Error: cannot locate the site's home directory.")

    args = parser.get_args()
    if len(args) < 2:
        sys.exit("Error: the 'edit' command requires at least 2 arguments.")

    paths = [site.src('[%s]' % args[0], path) for path in args[1:]]

    for path in paths:
        if not os.path.exists(path):
            now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            template = "---\ntitle: Record Title\ndate: %s\n---\n\n\n"
            utils.writefile(path, template % now)

    paths.insert(0, os.getenv('ARK_EDITOR') or os.getenv('EDITOR') or 'vim')
    subprocess.call(paths)
Esempio n. 2
0
def cmd_edit(parser):
    if not site.home():
        sys.exit("Error: cannot locate the site's home directory.")

    args = parser.get_args()
    if len(args) < 2:
        sys.exit("Error: the 'edit' command requires at least 2 arguments.")

    paths = [site.src('[%s]' % args[0], path) for path in args[1:]]

    for path in paths:
        if not os.path.exists(path):
            now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
            template = "---\ntitle: Record Title\ndate: %s\n---\n\n\n"
            utils.writefile(path, template % now)

    editor = os.getenv('ARK_EDITOR') or os.getenv('EDITOR') or 'vim'
    if not shutil.which(editor):
        sys.exit("Error: cannot locate the editor '%s'." % editor)

    paths.insert(0, editor)
    subprocess.call(paths)
Esempio n. 3
0
File: cli.py Progetto: Camr0n/ark
 def build_callback():
     if os.path.isdir(site.src()):
         build.build_site()
     else:
         sys.exit("Error: cannot locate the site's source directory.")
Esempio n. 4
0
 def build_callback():
     if os.path.isdir(site.src()):
         build.build_site()
     else:
         sys.exit("Error: cannot locate the site's source directory.")