ntree stand alone command
This commit is contained in:
parent
6c4ad0dd3d
commit
80640bf19c
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from src.ntree_cmdline_parser import cmd_args
|
||||
from src.tree import NerdTree
|
||||
|
||||
if __name__ == '__main__':
|
||||
# print(cmd_args.path)
|
||||
# print(cmd_args.show_children_nodes)
|
||||
# print(cmd_args.show_father_subtree_info)
|
||||
path = cmd_args.path
|
||||
list_dir_first = cmd_args.list_directories_first
|
||||
|
||||
# opts for generatign the tree
|
||||
opts = {
|
||||
'items_to_exclude' : cmd_args.exclude or [],
|
||||
'list_dir_first' : list_dir_first
|
||||
}
|
||||
|
||||
ntree = NerdTree(path, opts=opts)
|
||||
ntree.print()
|
|
@ -0,0 +1,23 @@
|
|||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
cmd_parser = argparse.ArgumentParser(
|
||||
prog='ntree',
|
||||
description='A python version (probabily worst) of tree unix command',
|
||||
epilog="Thanks for using it! :)",
|
||||
)
|
||||
|
||||
cmd_parser.add_argument("path")
|
||||
# cmd_parser.add_argument("pattern")
|
||||
cmd_parser.add_argument("-e", "--exclude", action="append")
|
||||
cmd_parser.add_argument("-l", "--list-directories-first", action="store_true")
|
||||
|
||||
# start the command line parsing
|
||||
cmd_args = cmd_parser.parse_args()
|
||||
|
||||
p = cmd_args.path
|
||||
path = Path(p)
|
||||
|
||||
if not path.exists():
|
||||
print(f'Path: {p} dont\' exists')
|
||||
raise SystemExit(1)
|
Loading…
Reference in New Issue