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)
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)
def build_callback(): if os.path.isdir(site.src()): build.build_site() else: sys.exit("Error: cannot locate the site's source directory.")