Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pokedex.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def parse_arguments():
help="Enter the National Pokédex ID number of a Pokémon (e.g., 25 for Pikachu). "
"Overrides the 'name' argument if both are provided."
)
return parser.parse_args()
args = parser.parse_args()
return parser, args


def get_random_pokemon_id():
Expand Down Expand Up @@ -223,7 +224,7 @@ def main():
5. Provides clear usage instructions and exits if no valid Pokémon
identifier or lookup method is provided.
"""
args = parse_arguments()
parser, args = parse_arguments()

identifier = None
if args.random:
Expand All @@ -239,7 +240,7 @@ def main():

print(f"{Fore.YELLOW}Error: No Pokémon specified. Please provide a name/ID or use --random.{Style.RESET_ALL}")

parse_arguments().print_help()
parser.print_help()
sys.exit(1)

# Fetch Pokémon data using the determined identifier.
Expand Down
23 changes: 12 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
import os

def run_command(command, description):
"""Run a command and handle errors."""
print(f"🔄 {description}...")
try:
result = subprocess.run(command, shell=True, check=True, capture_output=True, text=True)
subprocess.run(command, check=True)
print(f"✅ {description} completed successfully!")
return True
except subprocess.CalledProcessError as e:
print(f"❌ {description} failed!")
print(f"Error: {e.stderr}")
return False


def main():
print("🚀 Setting up PyDex development environment...")
print()
Expand All @@ -39,15 +38,17 @@ def main():
print("✅ Virtual environment already exists")

# Activate virtual environment and install requirements
if os.name == 'nt': # Windows
activate_cmd = "venv\\Scripts\\activate"
pip_cmd = "venv\\Scripts\\pip"
else: # Unix/Linux/macOS
activate_cmd = "source venv/bin/activate"
pip_cmd = "venv/bin/pip"

if not run_command(f"{pip_cmd} install -r requirements.txt", "Installing dependencies"):
if os.name == "nt":
venv_python = os.path.join("venv", "Scripts", "python")
else:
venv_python = os.path.join("venv", "bin", "python")

if not run_command(
[venv_python, "-m", "pip", "install", "-r", "requirements.txt"],
"Installing dependencies"
):
sys.exit(1)


print()
print("🎉 Setup completed successfully!")
Expand Down