mirror of
				https://github.com/kevinveenbirkenbach/directory-content-scanner.git
				synced 2025-11-04 11:58:11 +00:00 
			
		
		
		
	Optimized parameter
This commit is contained in:
		
							
								
								
									
										78
									
								
								cli.py
									
									
									
									
									
								
							
							
						
						
									
										78
									
								
								cli.py
									
									
									
									
									
								
							@@ -4,16 +4,68 @@ def parse_arguments():
 | 
				
			|||||||
    parser = argparse.ArgumentParser(
 | 
					    parser = argparse.ArgumentParser(
 | 
				
			||||||
        description="Scan directories and print/compile file contents."
 | 
					        description="Scan directories and print/compile file contents."
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    parser.add_argument("paths", nargs='+', help="List of files or directories to scan.")
 | 
					    parser.add_argument(
 | 
				
			||||||
    parser.add_argument("--file-types", nargs='+', default=[], help="Filter by file types (e.g., .txt, .log).")
 | 
					        "paths",
 | 
				
			||||||
    parser.add_argument("--ignore-file-strings", nargs='+', default=[], help="Ignore files and folders containing these strings.")
 | 
					        nargs='+',
 | 
				
			||||||
    parser.add_argument("--ignore-hidden", action='store_true', help="Ignore hidden directories and files.")
 | 
					        help="List of files or directories to scan."
 | 
				
			||||||
    parser.add_argument("-v", "--verbose", action='store_true', help="Enable verbose mode.")
 | 
					    )
 | 
				
			||||||
    parser.add_argument("--no-comments", action='store_true', help="Remove comments from the displayed content based on file type.")
 | 
					    parser.add_argument(
 | 
				
			||||||
    parser.add_argument("--compress", action='store_true', help="Compress code (for supported file types).")
 | 
					        "-t", "--file-types",
 | 
				
			||||||
    parser.add_argument("--path-contains", nargs='+', default=[], help="Display files whose paths contain one of these strings.")
 | 
					        nargs='+',
 | 
				
			||||||
    parser.add_argument("--content-contains", nargs='+', default=[], help="Display files containing one of these strings in their content.")
 | 
					        default=[],
 | 
				
			||||||
    parser.add_argument("--no-gitignore", action='store_true', help="Do not respect .gitignore files during scan.")
 | 
					        help="Filter by file types (e.g., .txt, .log)."
 | 
				
			||||||
    parser.add_argument("--scan-binary-files", action='store_true', help="Scan binary files as well (by default these are ignored).")
 | 
					    )
 | 
				
			||||||
    
 | 
					    parser.add_argument(
 | 
				
			||||||
    return parser.parse_args()
 | 
					        "-x", "--ignore-file-strings",
 | 
				
			||||||
 | 
					        nargs='+',
 | 
				
			||||||
 | 
					        default=[],
 | 
				
			||||||
 | 
					        help="Ignore files and folders containing these strings."
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    parser.add_argument(
 | 
				
			||||||
 | 
					        "-S", "--show-hidden",
 | 
				
			||||||
 | 
					        action='store_true',
 | 
				
			||||||
 | 
					        dest='show_hidden',
 | 
				
			||||||
 | 
					        default=False,
 | 
				
			||||||
 | 
					        help="Include hidden directories and files in the scan."
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    parser.add_argument(
 | 
				
			||||||
 | 
					        "-v", "--verbose",
 | 
				
			||||||
 | 
					        action='store_true',
 | 
				
			||||||
 | 
					        help="Enable verbose mode."
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    parser.add_argument(
 | 
				
			||||||
 | 
					        "-N", "--no-comments",
 | 
				
			||||||
 | 
					        action='store_true',
 | 
				
			||||||
 | 
					        help="Remove comments from the displayed content based on file type."
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    parser.add_argument(
 | 
				
			||||||
 | 
					        "-z", "--compress",
 | 
				
			||||||
 | 
					        action='store_true',
 | 
				
			||||||
 | 
					        help="Compress code (for supported file types)."
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    parser.add_argument(
 | 
				
			||||||
 | 
					        "-p", "--path-contains",
 | 
				
			||||||
 | 
					        nargs='+',
 | 
				
			||||||
 | 
					        default=[],
 | 
				
			||||||
 | 
					        help="Display files whose paths contain one of these strings."
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    parser.add_argument(
 | 
				
			||||||
 | 
					        "-C", "--content-contains",
 | 
				
			||||||
 | 
					        nargs='+',
 | 
				
			||||||
 | 
					        default=[],
 | 
				
			||||||
 | 
					        help="Display files containing one of these strings in their content."
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    parser.add_argument(
 | 
				
			||||||
 | 
					        "-G", "--no-gitignore",
 | 
				
			||||||
 | 
					        action='store_true',
 | 
				
			||||||
 | 
					        help="Do not respect .gitignore files during scan."
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    parser.add_argument(
 | 
				
			||||||
 | 
					        "-b", "--scan-binary-files",
 | 
				
			||||||
 | 
					        action='store_true',
 | 
				
			||||||
 | 
					        help="Scan binary files as well (by default these are ignored)."
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    # Convert show_hidden to ignore_hidden for downstream use
 | 
				
			||||||
 | 
					    args = parser.parse_args()
 | 
				
			||||||
 | 
					    args.ignore_hidden = not args.show_hidden
 | 
				
			||||||
 | 
					    return args
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user