codefetch-cli 1.2.6__py3-none-any.whl → 1.2.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
codefetch/__init__.py CHANGED
@@ -16,7 +16,7 @@ Usage in Python:
16
16
  files = cf.list("torvalds/linux")
17
17
  """
18
18
 
19
- __version__ = "1.2.6"
19
+ __version__ = "1.2.7"
20
20
 
21
21
 
22
22
  def get(target, filename=None, branch=None):
codefetch/cli.py CHANGED
@@ -18,7 +18,7 @@ DEFAULT_REPO = None
18
18
 
19
19
  CONFIG_FILE = Path.home() / ".codefetch.json"
20
20
 
21
- __version__ = "1.2.6"
21
+ __version__ = "1.2.7"
22
22
 
23
23
  # Supported code, data, and config extensions
24
24
  CODE_EXTENSIONS = {
@@ -641,7 +641,7 @@ def fetch_file(filename, owner=None, repo=None, branch=None,
641
641
 
642
642
 
643
643
  def parse_version_tuple(v_str):
644
- """Parse version string like '1.2.6' into a comparable tuple of integers."""
644
+ """Parse version string like '1.2.7' into a comparable tuple of integers."""
645
645
  try:
646
646
  return tuple(int(x) for x in re.findall(r"\d+", v_str))
647
647
  except Exception:
@@ -672,22 +672,40 @@ def update_codefetch():
672
672
  return
673
673
 
674
674
  print(f"Update available: v{latest_version} (current: v{__version__})")
675
- print(f"Updating {package_name}...")
676
675
  else:
677
- print(f"Updating {package_name} to latest version...")
678
-
679
- cmd = [sys.executable, "-m", "pip", "install", "--upgrade", package_name]
680
- try:
681
- result = subprocess.run(cmd)
682
- if result.returncode == 0:
683
- target_v = f"v{latest_version}" if latest_version else "the latest version"
684
- print(f"\nSuccessfully updated CodeFetch to {target_v}!")
685
- else:
686
- print(f"\nUpdate failed (exit code {result.returncode}).")
676
+ print(f"Checking {package_name}...")
677
+
678
+ print(f"Updating {package_name}...")
679
+
680
+ if sys.platform == "win32":
681
+ # On Windows, pip cannot overwrite codefetch.exe while this process is executing it.
682
+ # Spawn PowerShell to wait 800ms for this process to exit, then run pip install cleanly.
683
+ target_v = f"v{latest_version}" if latest_version else "latest version"
684
+ ps_cmd = (
685
+ f"Start-Sleep -Milliseconds 800; "
686
+ f"& '{sys.executable}' -m pip install --upgrade {package_name}; "
687
+ f"if ($LASTEXITCODE -eq 0) {{ Write-Host '`nSuccessfully updated CodeFetch to {target_v}!' }} "
688
+ f"else {{ Write-Host '`nUpdate failed. You can manually update with: pip install --upgrade {package_name}' }}"
689
+ )
690
+ try:
691
+ subprocess.Popen(["powershell", "-NoProfile", "-Command", ps_cmd])
692
+ sys.exit(0)
693
+ except Exception as e:
694
+ print(f"\nError launching updater: {e}")
695
+ print(f"You can manually update with: pip install --upgrade {package_name}")
696
+ else:
697
+ cmd = [sys.executable, "-m", "pip", "install", "--upgrade", package_name]
698
+ try:
699
+ result = subprocess.run(cmd)
700
+ if result.returncode == 0:
701
+ target_v = f"v{latest_version}" if latest_version else "the latest version"
702
+ print(f"\nSuccessfully updated CodeFetch to {target_v}!")
703
+ else:
704
+ print(f"\nUpdate failed (exit code {result.returncode}).")
705
+ print(f"You can manually update with: pip install --upgrade {package_name}")
706
+ except Exception as e:
707
+ print(f"\nError running update: {e}")
687
708
  print(f"You can manually update with: pip install --upgrade {package_name}")
688
- except Exception as e:
689
- print(f"\nError running update: {e}")
690
- print(f"You can manually update with: pip install --upgrade {package_name}")
691
709
 
692
710
 
693
711
  def uninstall_codefetch(yes=False):
@@ -712,17 +730,35 @@ def uninstall_codefetch(yes=False):
712
730
  pass
713
731
 
714
732
  print("Uninstalling codefetch-cli...")
715
- cmd = [sys.executable, "-m", "pip", "uninstall", "-y", "codefetch-cli"]
716
- try:
717
- result = subprocess.run(cmd)
718
- if result.returncode == 0:
719
- print("\nSuccessfully uninstalled CodeFetch.")
720
- else:
721
- print(f"\nUninstall failed (exit code {result.returncode}).")
733
+
734
+ if sys.platform == "win32":
735
+ # On Windows, pip cannot delete codefetch.exe while this process is executing it.
736
+ # Spawn PowerShell to wait 800ms for this process to exit, then run pip uninstall cleanly.
737
+ ps_cmd = (
738
+ f"Start-Sleep -Milliseconds 800; "
739
+ f"& '{sys.executable}' -m pip uninstall -y codefetch-cli; "
740
+ f"& '{sys.executable}' -m pip uninstall -y codefetch; "
741
+ f"if ($LASTEXITCODE -eq 0) {{ Write-Host '`nSuccessfully uninstalled CodeFetch.' }} "
742
+ f"else {{ Write-Host '`nUninstall failed. You can manually uninstall with: pip uninstall codefetch-cli' }}"
743
+ )
744
+ try:
745
+ subprocess.Popen(["powershell", "-NoProfile", "-Command", ps_cmd])
746
+ sys.exit(0)
747
+ except Exception as e:
748
+ print(f"\nError launching uninstaller: {e}")
749
+ print("You can manually uninstall with: pip uninstall codefetch-cli")
750
+ else:
751
+ cmd = [sys.executable, "-m", "pip", "uninstall", "-y", "codefetch-cli"]
752
+ try:
753
+ result = subprocess.run(cmd)
754
+ if result.returncode == 0:
755
+ print("\nSuccessfully uninstalled CodeFetch.")
756
+ else:
757
+ print(f"\nUninstall failed (exit code {result.returncode}).")
758
+ print("You can manually uninstall with: pip uninstall codefetch-cli")
759
+ except Exception as e:
760
+ print(f"\nError during uninstall: {e}")
722
761
  print("You can manually uninstall with: pip uninstall codefetch-cli")
723
- except Exception as e:
724
- print(f"\nError during uninstall: {e}")
725
- print("You can manually uninstall with: pip uninstall codefetch-cli")
726
762
 
727
763
 
728
764
  class CodefetchParser(argparse.ArgumentParser):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codefetch-cli
3
- Version: 1.2.6
3
+ Version: 1.2.7
4
4
  Summary: Quickly fetch code files from GitHub repositories with simple commands
5
5
  Home-page: https://github.com/InzamamulQureshi/Codefetch
6
6
  Author: Inzamamul Qureshi
@@ -0,0 +1,8 @@
1
+ codefetch/__init__.py,sha256=EAW6IcgeS_uiMy93B-9o_PcTyHWV_4Ip9OqOoHr79lk,5049
2
+ codefetch/cli.py,sha256=XaWCOBZQiMkYt2nR5-JzUrnxjOsX7dcXnifxiDM4BxE,37896
3
+ codefetch_cli-1.2.7.dist-info/licenses/LICENSE,sha256=hqEPPm8jxPava5BfKIj3wTIXNyWNwsIvPv2daPCOijY,1094
4
+ codefetch_cli-1.2.7.dist-info/METADATA,sha256=qxm_k1yE8U948v8U-bIh2-gvYcY2mjkN0ncJpAsNkBk,7262
5
+ codefetch_cli-1.2.7.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
6
+ codefetch_cli-1.2.7.dist-info/entry_points.txt,sha256=jFLRsBB_USeSdqjewcXZfnOzY56s0PZat7mnYkYdrXg,49
7
+ codefetch_cli-1.2.7.dist-info/top_level.txt,sha256=kHrftHbyqugb8LQXjW1dR9uI-JFjZQJ0sUReIa45yXQ,10
8
+ codefetch_cli-1.2.7.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- codefetch/__init__.py,sha256=jtbbu9FIih6Rys0rw-qtWaaMhwpalny5LAKNralmYmk,5049
2
- codefetch/cli.py,sha256=BCqYq8idjn8qIgMnXC2BS9_G1vKhLeeML4DMZNRuVWM,35887
3
- codefetch_cli-1.2.6.dist-info/licenses/LICENSE,sha256=hqEPPm8jxPava5BfKIj3wTIXNyWNwsIvPv2daPCOijY,1094
4
- codefetch_cli-1.2.6.dist-info/METADATA,sha256=nbqiiyqFOItehpLK9YYbSv8uOoQnh_uJlnwqvgDZdH8,7262
5
- codefetch_cli-1.2.6.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
6
- codefetch_cli-1.2.6.dist-info/entry_points.txt,sha256=jFLRsBB_USeSdqjewcXZfnOzY56s0PZat7mnYkYdrXg,49
7
- codefetch_cli-1.2.6.dist-info/top_level.txt,sha256=kHrftHbyqugb8LQXjW1dR9uI-JFjZQJ0sUReIa45yXQ,10
8
- codefetch_cli-1.2.6.dist-info/RECORD,,