cmd help
This commit is contained in:
parent
5f8875389e
commit
b718c06a11
1 changed files with 35 additions and 35 deletions
|
|
@ -65,45 +65,46 @@ def main():
|
|||
|
||||
console = Console()
|
||||
|
||||
command_help = """{add,a} FILE [CONTEXT ...]
|
||||
{remove,rem,r} FILE [CONTEXT ...]
|
||||
command_help = """{add,a} FILE CONTEXT # add context to an existing file
|
||||
{remove,r} FILE CONTEXT # remove context from an existing file
|
||||
{list,ls,l} QUERY # list all files with queried context in current directory tree
|
||||
|
||||
{copy,cp} SOURCE DEST
|
||||
{move,mv} SOURCE DEST
|
||||
{del,rm} FILE
|
||||
{copy,cp} SOURCE DEST # copy file and its context to another directory
|
||||
{move,mv} SOURCE DEST # move file and its context to another directory
|
||||
{del,rm} FILE # delete file and its context
|
||||
|
||||
{clear,c} FILE
|
||||
{clean} PATH
|
||||
{clean,c} PATH # remove all context for nonexisting files
|
||||
{purge,p} PATH # remove all context for all files in current directory tree
|
||||
|
||||
{list,ls,dir,l} QUERY
|
||||
{listproj,lsprj} QUERY
|
||||
{listcon,lsc} QUERY
|
||||
{listtag,lst} QUERY
|
||||
{write,w} PLUGIN FILE # write all context of a file to the file as metadata
|
||||
{import,i} FILE # import context for files from a text file
|
||||
{export,e} FILE # export context for files to a text file
|
||||
"""
|
||||
|
||||
p = argp(description="OrvaniTagger", formatter_class=raw)
|
||||
p.add_argument("--not-recursive", "-nr", action="store_false", help="Include subdirectories in search")
|
||||
p.add_argument("--no-file_operation", "-nf", action="store_false", help="Copy/Move/Delete file, not just context")
|
||||
p.add_argument("--no-plugins", "-np", action="store_false", help="Don't use plug-ins to search file metadata")
|
||||
p.add_argument("--path", "-p", action="store", type=str, help="List/search custom path", default='')
|
||||
p.add_argument("--exact", "-e", action="store_true", help="Match exact search term")
|
||||
p.add_argument("--files", "-f", action="store_true", help="Only show files, ignore folders")
|
||||
p.add_argument("--dirs", "-d", action="store_true", help="Only show directories, ignore files")
|
||||
p.add_argument("--either", "-or", action="store_true", help="Combine search terms by OR instead of AND")
|
||||
p.add_argument("--cache", "-c", action="store_true", help="Cache index search (useful with deep directory trees)")
|
||||
p.add_argument("--delete-cache", "-dc", action="store_true", help="Delete cache file")
|
||||
p.add_argument("--not-recursive", "-nr", action="store_false", help="(list,clean,purge,export) Include subdirectories in search")
|
||||
p.add_argument("--no-file-operation", "-nf", action="store_false", help="(copy,move,del) Skip file operation, just apply to context")
|
||||
p.add_argument("--no-plugins", "-np", action="store_false", help="(list,export) Don't use plug-ins to search file metadata")
|
||||
p.add_argument("--path", "-p", action="store", type=str, help="(list,export) Use custom path", default='')
|
||||
p.add_argument("--exact", "-e", action="store_true", help="(list) Match exact search term")
|
||||
p.add_argument("--files", "-f", action="store_true", help="(list) Only show files, ignore folders")
|
||||
p.add_argument("--dirs", "-d", action="store_true", help="(list) Only show directories, ignore files")
|
||||
p.add_argument("--either", "-or", action="store_true", help="(list) Combine search terms by OR instead of AND")
|
||||
p.add_argument("--cache", "-c", action="store_true", help="(list) Cache index search (useful with deep directory trees)")
|
||||
p.add_argument("--delete-cache", "-dc", action="store_true", help="(list) Delete cache file")
|
||||
p.add_argument("command", nargs="?", default=None, metavar='Command',
|
||||
help=command_help, type=str,
|
||||
choices=[
|
||||
'add', 'a',
|
||||
'remove', 'rem', 'r',
|
||||
'list', 'ls', 'dir', 'l',
|
||||
'remove', 'r',
|
||||
'list', 'ls', 'l',
|
||||
'copy', 'cp',
|
||||
'move', 'mv',
|
||||
'del', 'rm',
|
||||
'clean', 'purge',
|
||||
'write',
|
||||
'import', 'export'
|
||||
'clean', 'c',
|
||||
'purge', 'p'
|
||||
'write', 'w',
|
||||
'import', 'i',
|
||||
'export', 'e'
|
||||
])
|
||||
p.add_argument("file", nargs="?", type=str, help=SUPPRESS)
|
||||
p.add_argument("context", nargs="*", type=str, help=SUPPRESS)
|
||||
|
|
@ -111,7 +112,6 @@ def main():
|
|||
args = p.parse_args()
|
||||
|
||||
orvani = OrvaniTag()
|
||||
|
||||
orvani.ENABLE_PLUGINS = args.no_plugins
|
||||
|
||||
try:
|
||||
|
|
@ -123,7 +123,7 @@ def main():
|
|||
elif fb[0] == 1:
|
||||
console.print(f":thinking_face: File [strong]{fb[1]}[/strong] doesn't exist.")
|
||||
|
||||
elif args.command in ['remove', 'rem', 'r']:
|
||||
elif args.command in ['remove', 'r']:
|
||||
if args.file and args.context:
|
||||
fb = orvani.remove(args.file, *args.context)
|
||||
if fb[0] == 0:
|
||||
|
|
@ -133,7 +133,7 @@ def main():
|
|||
elif fb[0] == 2:
|
||||
console.print(f":mag: No match found for [white][strong]{fb[1]}[/strong][/white] and {nice_context(fb[2])}")
|
||||
|
||||
elif args.command in ['list', 'ls', 'dir', 'l']:
|
||||
elif args.command in ['list', 'ls', 'l']:
|
||||
query = [args.file] + args.context
|
||||
if query:
|
||||
r = orvani.list(args.path, args.exact, args.either, args.not_recursive, args.cache, args.delete_cache, *query)
|
||||
|
|
@ -186,7 +186,7 @@ def main():
|
|||
console.print(f":mag: No entry for [strong]{fb[1]}[/strong] found.")
|
||||
|
||||
|
||||
elif args.command in ['purge']:
|
||||
elif args.command in ['purge', 'p']:
|
||||
|
||||
def purge(path):
|
||||
target = Path(path)
|
||||
|
|
@ -211,7 +211,7 @@ def main():
|
|||
pp = os.path.join(root, dir)
|
||||
purge(pp)
|
||||
|
||||
elif args.command in ['clean']:
|
||||
elif args.command in ['clean', 'c']:
|
||||
if not args.file:
|
||||
args.file = ''
|
||||
fb = orvani.clean(args.file, args.not_recursive)
|
||||
|
|
@ -221,7 +221,7 @@ def main():
|
|||
sub = ' and subdirectories'
|
||||
console.print(f':broom: {fb[2]} entries cleaned from [strong]{fb[1]}[/strong]{sub}')
|
||||
|
||||
elif args.command in ['write']:
|
||||
elif args.command in ['write', 'w']:
|
||||
if args.file and args.context:
|
||||
fb = orvani.write(args.context[0], args.file)
|
||||
if fb[0] == 0:
|
||||
|
|
@ -233,14 +233,14 @@ def main():
|
|||
if fb[0] == 5:
|
||||
console.print(f':disappointed: Plugin [strong]{fb[1]}[/strong] can\'t write.')
|
||||
|
||||
elif args.command in ['export']:
|
||||
elif args.command in ['export', 'e']:
|
||||
fb = orvani.export(args.file)
|
||||
if fb[0] == 0:
|
||||
console.print(f':floppy_disk: All entries successfully written to file [strong]{fb[1]}[/strong].')
|
||||
elif fb[0] == 2:
|
||||
console.print(f":mag: No entries found.")
|
||||
|
||||
elif args.command in ['import']:
|
||||
elif args.command in ['import', 'i']:
|
||||
|
||||
fb = orvani.load(args.file)
|
||||
if fb[0] == 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue