7a4a91ec863f

Add usage text.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 19 Sep 2012 23:37:28 -0400
parents 2356bfd686af
children c2b6722131ff
branches/tags (none)
files ffind

Changes

--- a/ffind	Wed Sep 19 23:00:23 2012 -0400
+++ b/ffind	Wed Sep 19 23:37:28 2012 -0400
@@ -8,11 +8,133 @@
 #
 #                         The friendlier file finder.
 
+from optparse import OptionParser, OptionGroup
+
 def build_option_parser():
-    pass
+    p = OptionParser()
+
+    # Main options
+    p.add_option('-r', '--root',
+                 help='root the search in DIR',
+                 metavar='DIR')
+    p.add_option('-d', '--depth',
+                 help='search at most N directories deep',
+                 metavar='N')
+    p.add_option('-f', '--follow',
+                 action='store_true', default=False,
+                 help='follow symlinked directories and search their contents')
+    p.add_option('-0', '--print0', dest='zero',
+                 action='store_true', default=False,
+                 help='separate matches with a null byte in output')
+    p.add_option('-l', '--literal',
+                 action='store_true', default=False,
+                 help='force literal search, even if it looks like a regex')
+    p.add_option('-i', '--insensitive',
+                 action='store_true', default=False,
+                 help='case insensitive matching')
+    p.add_option('-v', '--invert',
+                 action='store_true', default=False,
+                 help='invert match')
+
+    # Ignoring
+    g = OptionGroup(p, "Configuring Ignoring")
+    g.add_option('-b', '--no-binary',
+                 action='store_true', default=False,
+                 help='ignore binary files')
+    g.add_option('-a', '--all',
+                 action='store_true', default=False,
+                 help="don't ignore anything (ALL files can match)")
+    g.add_option('-u', '--unrestricted',
+                 action='store_true', default=False,
+                 help="unrestricted search (don't parse ignore files, but still skip VCS directories)")
+    g.add_option('-q', '--restricted',
+                 action='store_true', default=False,
+                 help="restricted search (don't parse VCS ignore files, but still skip VCS directories and parse .ffignore)")
+    p.add_option_group(g)
+
+    # Time filtering
+    g = OptionGroup(p, "Time Filtering")
+    g.add_option('--before',
+                 help='match files modified < TIME',
+                 metavar='TIME')
+    g.add_option('--after',
+                 help='match files modified > TIME',
+                 metavar='TIME')
+    g.add_option('--until',
+                 help='match files modified <= TIME',
+                 metavar='TIME')
+    g.add_option('--since',
+                 help='match files modified >= TIME',
+                 metavar='TIME')
+    g.add_option('--at',
+                 help='match files modified at TIME',
+                 metavar='TIME')
+    g.add_option('--created-before',
+                 help='match files created < TIME',
+                 metavar='TIME')
+    g.add_option('--created-after',
+                 help='match files created > TIME',
+                 metavar='TIME')
+    g.add_option('--created-until',
+                 help='match files created <= TIME',
+                 metavar='TIME')
+    g.add_option('--created-since',
+                 help='match files created >= TIME',
+                 metavar='TIME')
+    g.add_option('--created-at',
+                 help='match files modified at TIME',
+                 metavar='TIME')
+    p.add_option_group(g)
+
+    # Size filtering
+    g = OptionGroup(p, "Size Filtering",
+                    "Sizes can be given as a number followed by a prefix.  Some examples: "
+                    "1k, 5kb, 1.5gb, 2g, 1024b")
+    g.add_option('--larger-than',
+                 help='match files larger than SIZE (inclusive)',
+                 metavar='SIZE')
+    g.add_option('--smaller-than',
+                 help='match files smaller than SIZE (inclusive)',
+                 metavar='SIZE')
+    p.add_option_group(g)
+
+    # Type filtering
+    g = OptionGroup(p, "Type Filtering",
+                    "A thing is a file or a directory.")
+    g.add_option('-A', '--type-all', dest='type_all',
+                 action='store_true', default=False,
+                 help='match all things (default)')
+    g.add_option('-F', '--type-file', dest='type_file',
+                 action='store_true', default=False,
+                 help='match any kind of file')
+    g.add_option('-D', '--type-dir', dest='type_dir',
+                 action='store_true', default=False,
+                 help='match any kind of directory')
+    g.add_option('-R', '--type-real', dest='type_real',
+                 action='store_true', default=False,
+                 help='match real things')
+    g.add_option('-S', '--type-symlink', dest='type_symlink',
+                 action='store_true', default=False,
+                 help='match symlink things')
+    g.add_option('-E', '--type-file-real', dest='type_file_real',
+                 action='store_true', default=False,
+                 help='match real (non-symlink) files')
+    g.add_option('-C', '--type-dir-real', dest='type_dir_real',
+                 action='store_true', default=False,
+                 help='match real (non-symlink) directories')
+    g.add_option('-X', '--type-file-symlink', dest='type_file_symlink',
+                 action='store_true', default=False,
+                 help='match symlink files')
+    g.add_option('-Y', '--type-dir-symlink', dest='type_dir_symlink',
+                 action='store_true', default=False,
+                 help='match symlink directories')
+    p.add_option_group(g)
+
+    return p
 
 def main():
-    pass
+    (options, args) = build_option_parser().parse_args()
+    print options, args
 
 if __name__ == '__main__':
     main()