Add files via upload

This commit is contained in:
Gerald-H 2024-11-28 14:26:39 +01:00 committed by GitHub
parent 2ca76b9b36
commit 3a942324e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 81 additions and 0 deletions

31
ggtree.py Normal file
View File

@ -0,0 +1,31 @@
import os
# Metadata
version = "1.0.4"
author = "Gerald Hasani"
name = "GGTree"
email = "contact@gerald-hasani.com"
github = "https://github.com/Gerald-Ha"
def print_tree(start_path=".", prefix=""):
"""
Print the directory tree structure starting from `start_path`.
:param start_path: Root directory to start building the tree.
:param prefix: Indentation for the current level of the tree.
"""
entries = sorted(os.listdir(start_path))
entries_count = len(entries)
for index, entry in enumerate(entries):
path = os.path.join(start_path, entry)
connector = "└── " if index == entries_count - 1 else "├── "
print(prefix + connector + entry)
if os.path.isdir(path):
extension = " " if index == entries_count - 1 else ""
print_tree(path, prefix + extension)
if __name__ == "__main__":
print("Directory tree for:", os.getcwd())
print_tree()

31
install.sh Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# Install script for ggtree
# Define the target directory for the binary
BIN_DIR="/usr/local/bin"
SCRIPT_NAME="ggtree"
# Copy the Python script to /usr/local/bin
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" >&2
exit 1
fi
SCRIPT_PATH="$(pwd)/ggtree.py"
TARGET_PATH="$BIN_DIR/$SCRIPT_NAME"
if [[ ! -f "$SCRIPT_PATH" ]]; then
echo "ggtree.py not found in the current directory. Aborting installation." >&2
exit 1
fi
# Create a wrapper to call the Python script
cat << WRAPPER > "$TARGET_PATH"
#!/bin/bash
python3 "$SCRIPT_PATH"
WRAPPER
# Make the wrapper executable
chmod +x "$TARGET_PATH"
echo "ggtree installed successfully. You can now use the command 'ggtree' from anywhere."

19
uninstall.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
# Uninstall script for ggtree
# Define the target directory for the binary
BIN_DIR="/usr/local/bin"
SCRIPT_NAME="ggtree"
TARGET_PATH="$BIN_DIR/$SCRIPT_NAME"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" >&2
exit 1
fi
if [[ -f "$TARGET_PATH" ]]; then
rm "$TARGET_PATH"
echo "ggtree has been uninstalled."
else
echo "ggtree is not installed."
fi