mirror of
https://github.com/Gerald-Ha/GGTree.git
synced 2025-04-08 06:53:20 +00:00
Add files via upload
This commit is contained in:
parent
2ca76b9b36
commit
3a942324e2
31
ggtree.py
Normal file
31
ggtree.py
Normal 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
31
install.sh
Normal 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
19
uninstall.sh
Normal 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
|
Loading…
Reference in New Issue
Block a user