Skip to content

Commit

Permalink
ptig grep help from ptgrep
Browse files Browse the repository at this point in the history
  • Loading branch information
clach04 committed Oct 19, 2024
1 parent 8ffa42f commit 5b2d56d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion puren_tonbo/tools/ptgrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def main(argv=None):
# TODO mix of snake_case and hypen-case flags/options; list-formats/list_formats and note-root/note_root
parser = MyParser(usage=usage, version="%%prog %s" % puren_tonbo.__version__,
description=ptgrep_description,
epilog =ptgrep_examples
epilog=ptgrep_examples
)
parser.add_option("--list-formats", help="Which encryption/file formats are available", action="store_true")
parser.add_option("--note-root", help="Directory of notes, or dir_name_or_filename1.... will pick up from config file and default to '.'")
Expand Down
9 changes: 5 additions & 4 deletions puren_tonbo/tools/ptig.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import copy
import json
import os
from optparse import OptionParser
import pydoc
import shlex
import sys
Expand Down Expand Up @@ -114,9 +113,11 @@ def __repr__(self):

# Extracted (subset) from ptgrep.main()
# FIXME refactor ptgrep to have a shared, reusable parser and use here. E.g. would add support for -t
grep_parser = OptionParser(usage='usage: %prog [options] [search_term]',
grep_parser = ptgrep.MyParser(usage='usage: %prog [options] [search_term]',
prog='grep',
description='A grep/ripprep like tool. Use "--" to specify search terms that start with a hype "-"')
description=ptgrep.ptgrep_description,
epilog =ptgrep.ptgrep_examples
)
grep_parser.add_option("-i", "--ignore_case", help="Case insensitive search", action="store_true")
grep_parser.add_option("-y", "--find-only-filename", "--find_only_filename", help="Only search filenames, do not search file content", action="store_true")
grep_parser.add_option("-l", "--files-with-matches", "--files_with_matches", help="Only print filenames that contain matches", action="store_true")
Expand Down Expand Up @@ -1038,7 +1039,7 @@ def main(argv=None):
argv = sys.argv

usage = "usage: %prog [options] [search_term] [dir_name_or_filename1] [dir_name_or_filename2...]"
parser = OptionParser(usage=usage, version="%%prog %s" % puren_tonbo.__version__)
parser = ptgrep.MyParser(usage=usage, version="%%prog %s" % puren_tonbo.__version__)
parser.add_option("-c", "--codec", help="Override config file encoding (can be a list TODO format comma?)")
parser.add_option("--config-file", "--config_file", help="Override config file")
parser.add_option("--note-root", help="Directory of notes, or dir_name_or_filename1.... will pick up from config file and default to '.'")
Expand Down

0 comments on commit 5b2d56d

Please sign in to comment.