mirror of
https://github.com/kirill-markin/repo-to-text.git
synced 2025-12-06 03:22:23 -08:00
Detect if tree is missing
This commit is contained in:
parent
57f2e65a68
commit
695fc0d4f2
1 changed files with 13 additions and 0 deletions
|
|
@ -6,12 +6,25 @@ import argparse
|
|||
import yaml
|
||||
from datetime import datetime
|
||||
import pyperclip
|
||||
import shutil
|
||||
|
||||
def setup_logging(debug=False):
|
||||
logging_level = logging.DEBUG if debug else logging.INFO
|
||||
logging.basicConfig(level=logging_level, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
def check_tree_command():
|
||||
""" Check if the `tree` command is available, and suggest installation if not. """
|
||||
if shutil.which('tree') is None:
|
||||
print("The 'tree' command is not found. Please install it using one of the following commands:")
|
||||
print("For Debian-based systems (e.g., Ubuntu): sudo apt-get install tree")
|
||||
print("For Red Hat-based systems (e.g., Fedora, CentOS): sudo yum install tree")
|
||||
return False
|
||||
return True
|
||||
|
||||
def get_tree_structure(path='.', gitignore_spec=None, tree_and_content_ignore_spec=None) -> str:
|
||||
if not check_tree_command():
|
||||
return ""
|
||||
|
||||
logging.debug(f'Generating tree structure for path: {path}')
|
||||
result = subprocess.run(['tree', '-a', '-f', '--noreport', path], stdout=subprocess.PIPE)
|
||||
tree_output = result.stdout.decode('utf-8')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue