forked from crunk/distribusi-verse
90 lines
2.3 KiB
Python
90 lines
2.3 KiB
Python
|
import argparse
|
||
|
import os
|
||
|
|
||
|
from distribusi.distribusi import distribusify
|
||
|
|
||
|
|
||
|
def build_argparser():
|
||
|
parser = argparse.ArgumentParser(
|
||
|
"""
|
||
|
distribusi is a content management system for the web that produces static
|
||
|
index pages based on folders in the files system. It is inspired by the
|
||
|
automatic index functions featured in several popular web servers.
|
||
|
distribusi works by traversing the file system and directory hierarchy to
|
||
|
automatically list all the files in the directory, detect the file types
|
||
|
and providing them with relevant html classes and tags for easy styling.
|
||
|
"""
|
||
|
)
|
||
|
|
||
|
parser.add_argument(
|
||
|
"-d",
|
||
|
"--directory",
|
||
|
help="Select which directory to distribute",
|
||
|
default=".",
|
||
|
)
|
||
|
|
||
|
parser.add_argument(
|
||
|
"-s", "--style", help="Select a CSS style sheet to include"
|
||
|
)
|
||
|
|
||
|
parser.add_argument(
|
||
|
"-v",
|
||
|
"--verbose",
|
||
|
help="Print verbose debug output",
|
||
|
action="store_true",
|
||
|
)
|
||
|
|
||
|
parser.add_argument(
|
||
|
"-t",
|
||
|
"--thumbnail",
|
||
|
help="Generate 450x450 thumbnails for images",
|
||
|
action="store_true",
|
||
|
)
|
||
|
|
||
|
parser.add_argument(
|
||
|
"-a",
|
||
|
"--alttexts",
|
||
|
help="Adds file alttext based on same named files",
|
||
|
action="store_true",
|
||
|
)
|
||
|
|
||
|
parser.add_argument(
|
||
|
"-r",
|
||
|
"--remove-index",
|
||
|
help="Recursively removes all instances of index.html that have been previously made by distribusi",
|
||
|
action="store_true",
|
||
|
)
|
||
|
|
||
|
parser.add_argument(
|
||
|
"-e",
|
||
|
"--exclude-directory",
|
||
|
help="Exclude one or multiple directories from indexing",
|
||
|
nargs="*",
|
||
|
metavar="DIR",
|
||
|
)
|
||
|
|
||
|
parser.add_argument(
|
||
|
"-f",
|
||
|
"--force",
|
||
|
help="Force whether distribusi overwrites or removes instances of index.html not generated by distribusi, use at own risk!",
|
||
|
action="store_true",
|
||
|
)
|
||
|
|
||
|
parser.add_argument(
|
||
|
"--no-hidden", help="Exclude hidden directories", action="store_true"
|
||
|
)
|
||
|
|
||
|
parser.add_argument(
|
||
|
"--menu-with-index",
|
||
|
help="Append index.html to menu items to aid navigation",
|
||
|
action="store_true",
|
||
|
)
|
||
|
|
||
|
return parser
|
||
|
|
||
|
|
||
|
def cli_entrypoint():
|
||
|
parser = build_argparser()
|
||
|
args = parser.parse_args()
|
||
|
distribusify(args, args.directory)
|