def _subparse_list(subparsers): subparser_list = subparsers.add_parser( "list", aliases=["l"], help="List last search results." ) option_num(subparser_list) option_full_path(subparser_list) subparser_list.set_defaults(func=show)
def _subparse_empty_posts(subparsers): subparser_status = subparsers.add_parser( "empty", aliases=["em"], help="Find empty post." ) option_dry_run(subparser_status) option_num(subparser_status) option_full_path(subparser_status) subparser_status.set_defaults(func=empty_posts)
def _subparse_find_name_title_mismatch(subparsers): subparser_find_name_title_mismatch = subparsers.add_parser( "findmismatch", aliases=["fm"], help="Find posts where their name and title are mismatched." ) option_dry_run(subparser_find_name_title_mismatch) option_num(subparser_find_name_title_mismatch) option_full_path(subparser_find_name_title_mismatch) subparser_find_name_title_mismatch.set_defaults(func=find_name_title_mismatch)
def _subparse_search(subparsers): subparser_search = subparsers.add_parser( "search", aliases=["s"], help="Search for posts. " "Tokens separated by spaces ( ) or plus signs (+) in the search phrase " "are matched in order with tokens in the text. " "ORDERLESS match of tokens can be achieved by separating them with the AND keyword. " "You can also limit match into specific columns. " "For more information, please refer to https://sqlite.org/fts5.html" ) option_dry_run(subparser_search) subparser_search.add_argument( "phrase", nargs="*", default=(), help="The phrase to match in posts. " "The phrase is optional. " "For example if you want to filter by category only without constraints on full-text search, " "you can use ./blog.py s the -c some_category." ) subparser_search.add_argument( "-i", "--title", nargs="+", dest="title", default=(), help="Search for posts with the sepcified title." ) subparser_search.add_argument( "-I", "--neg-title", nargs="+", dest="neg_title", default=(), help="Search for posts without the sepcified title." ) subparser_search.add_argument( "-a", "--author", nargs="+", dest="author", default=(), help="Search for posts with the sepcified author." ) subparser_search.add_argument( "-A", "--neg-author", nargs="+", dest="neg_author", default=(), help="Search for posts without the sepcified author." ) subparser_search.add_argument( "-s", "--status", nargs="+", dest="status", default=(), help="Search for posts with the sepcified status." ) subparser_search.add_argument( "-S", "--neg-status", nargs="+", dest="neg_status", default=(), help="Search for posts without the sepcified status." ) subparser_search.add_argument( "-t", "--tags", nargs="+", dest="tags", default=(), help="Search for posts with the sepcified tags." ) subparser_search.add_argument( "-T", "--neg-tags", nargs="+", dest="neg_tags", default=(), help="Search for posts without the sepcified tags." ) subparser_search.add_argument( "-c", "--categories", nargs="+", dest="categories", default=(), help="Search for posts with the sepcified categories." ) subparser_search.add_argument( "-C", "--neg-categories", nargs="+", dest="neg_categories", default=(), help="Search for posts without the sepcified categories." ) subparser_search.add_argument( "-d", "--sub-dir", dest="sub_dir", nargs="+", default=(), help="Search for posts in the specified sub blog directory." ) subparser_search.add_argument( "-D", "--neg-sub-dir", dest="neg_sub_dir", nargs="+", default=(), help="Search for posts not in the specified sub blog directory." ) subparser_search.add_argument( "-f", "--filter", dest="filter", nargs="+", default=(), help="Futher filtering conditions in addition to the full-text match." ) option_num(subparser_search) option_full_path(subparser_search) subparser_search.set_defaults(func=search)