File size: 1,186 Bytes
69c20e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import shutil
import subprocess
import sys

def main():
    # Check Status
    gh_path = shutil.which('gh')
    
    if not gh_path:
        # Install
        print("GitHub CLI not found. Installing via winget...")
        try:
            subprocess.run(['winget', 'install', '--id', 'GitHub.cli', '-e'], check=True)
        except subprocess.CalledProcessError as e:
            print(f"Error installing GitHub CLI: {e}")
            return
        except FileNotFoundError:
            print("Error: 'winget' command not found. Please ensure App Installer is installed.")
            return
            
    # Post-Install Instructions (Runs if installed or if installation succeeded)
    print("\n" + "="*40)
    try:
        # Attempt to use ANSI codes for bold, may not work in all Windows terminals but works in VS Code / modern Windows Terminal
        print("βœ… \033[1mGitHub CLI is ready!\033[0m")
    except:
        print("βœ… GitHub CLI is ready!")
    print("="*40)
    print("⚠️  IMPORTANT: You must now restart your terminal to reload your PATH.")
    print("πŸ‘‰ After restarting, run this command to log in: gh auth login")

if __name__ == "__main__":
    main()