codefetch-cli 1.2.5__tar.gz → 1.2.7__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codefetch-cli
3
- Version: 1.2.5
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
@@ -36,6 +36,7 @@ CodeFetch is a lightweight command-line utility and Python library designed to q
36
36
  - **Repository Discovery**: List all public repositories for any GitHub user with `--repos`.
37
37
  - **Tree Exploration**: List all supported code files within a repository with `--list`.
38
38
  - **Self-Updating**: Keep CodeFetch updated to the latest PyPI release with `codefetch --update`.
39
+ - **Clean Uninstall**: Easily remove CodeFetch and its configuration with `codefetch --uninstall`.
39
40
  - **Python Library Support**: Import and use programmatically with `import codefetch as cf`.
40
41
  - **Optional Persistent Defaults**: Save a default repository or user with `--set-default` if you frequently work with the same repository.
41
42
  - **Zero Runtime Dependencies**: Built using only the Python standard library with zero third-party dependencies.
@@ -130,11 +131,14 @@ codefetch --config
130
131
  codefetch --reset-config
131
132
  ```
132
133
 
133
- ### 5. Self-Updating
134
+ ### 5. Package Management
134
135
 
135
136
  ```bash
136
137
  # Update CodeFetch to the latest version published on PyPI
137
138
  codefetch --update
139
+
140
+ # Uninstall CodeFetch and remove local configuration
141
+ codefetch --uninstall
138
142
  ```
139
143
 
140
144
  ---
@@ -176,7 +180,8 @@ print(f"Found {len(files)} files")
176
180
  | `--set-default-user` | Set persistent default user | `codefetch --set-default-user username` |
177
181
  | `--config` | Display active configuration | `codefetch --config` |
178
182
  | `--reset-config` | Reset configuration back to defaults | `codefetch --reset-config` |
179
- | `-U`, `--update` | Update CodeFetch to latest PyPI version | `codefetch --update` |
183
+ | `-U`, `--update` | Update CodeFetch to latest PyPI release | `codefetch --update` |
184
+ | `--uninstall` | Uninstall CodeFetch from your system | `codefetch --uninstall` |
180
185
  | `-v`, `--version` | Display version information | `codefetch --version` |
181
186
  | `-h`, `--help` | Display help and usage message | `codefetch --help` |
182
187
 
@@ -14,6 +14,7 @@ CodeFetch is a lightweight command-line utility and Python library designed to q
14
14
  - **Repository Discovery**: List all public repositories for any GitHub user with `--repos`.
15
15
  - **Tree Exploration**: List all supported code files within a repository with `--list`.
16
16
  - **Self-Updating**: Keep CodeFetch updated to the latest PyPI release with `codefetch --update`.
17
+ - **Clean Uninstall**: Easily remove CodeFetch and its configuration with `codefetch --uninstall`.
17
18
  - **Python Library Support**: Import and use programmatically with `import codefetch as cf`.
18
19
  - **Optional Persistent Defaults**: Save a default repository or user with `--set-default` if you frequently work with the same repository.
19
20
  - **Zero Runtime Dependencies**: Built using only the Python standard library with zero third-party dependencies.
@@ -108,11 +109,14 @@ codefetch --config
108
109
  codefetch --reset-config
109
110
  ```
110
111
 
111
- ### 5. Self-Updating
112
+ ### 5. Package Management
112
113
 
113
114
  ```bash
114
115
  # Update CodeFetch to the latest version published on PyPI
115
116
  codefetch --update
117
+
118
+ # Uninstall CodeFetch and remove local configuration
119
+ codefetch --uninstall
116
120
  ```
117
121
 
118
122
  ---
@@ -154,7 +158,8 @@ print(f"Found {len(files)} files")
154
158
  | `--set-default-user` | Set persistent default user | `codefetch --set-default-user username` |
155
159
  | `--config` | Display active configuration | `codefetch --config` |
156
160
  | `--reset-config` | Reset configuration back to defaults | `codefetch --reset-config` |
157
- | `-U`, `--update` | Update CodeFetch to latest PyPI version | `codefetch --update` |
161
+ | `-U`, `--update` | Update CodeFetch to latest PyPI release | `codefetch --update` |
162
+ | `--uninstall` | Uninstall CodeFetch from your system | `codefetch --uninstall` |
158
163
  | `-v`, `--version` | Display version information | `codefetch --version` |
159
164
  | `-h`, `--help` | Display help and usage message | `codefetch --help` |
160
165
 
@@ -16,7 +16,7 @@ Usage in Python:
16
16
  files = cf.list("torvalds/linux")
17
17
  """
18
18
 
19
- __version__ = "1.2.5"
19
+ __version__ = "1.2.7"
20
20
 
21
21
 
22
22
  def get(target, filename=None, branch=None):
@@ -18,7 +18,7 @@ DEFAULT_REPO = None
18
18
 
19
19
  CONFIG_FILE = Path.home() / ".codefetch.json"
20
20
 
21
- __version__ = "1.2.5"
21
+ __version__ = "1.2.7"
22
22
 
23
23
  # Supported code, data, and config extensions
24
24
  CODE_EXTENSIONS = {
@@ -63,6 +63,7 @@ USAGE:
63
63
  codefetch -l <owner>/<repo> List all code files in a repository
64
64
  codefetch -R <username> List public repositories for a user
65
65
  codefetch --update Update CodeFetch to the latest version
66
+ codefetch --uninstall Uninstall CodeFetch from your system
66
67
 
67
68
  POPULAR EXAMPLES:
68
69
  # Download from any repository:
@@ -80,6 +81,10 @@ POPULAR EXAMPLES:
80
81
  codefetch -l torvalds/linux # list files in a repo
81
82
  codefetch -R torvalds # list repos belonging to user
82
83
 
84
+ # Package management:
85
+ codefetch --update # update to latest PyPI release
86
+ codefetch --uninstall # uninstall CodeFetch package
87
+
83
88
  SETTING A DEFAULT REPOSITORY (OPTIONAL):
84
89
  If you frequently work with the same repo, you can set it as default:
85
90
  codefetch --set-default owner/repo # sets default repo
@@ -100,6 +105,8 @@ FLAGS & OPTIONS:
100
105
  --config Show current saved configuration
101
106
  --reset-config Reset configuration back to defaults
102
107
  -U, --update Update CodeFetch to the latest version from PyPI
108
+ --uninstall Uninstall CodeFetch from your system
109
+ -y, --yes Confirm uninstall without prompting
103
110
  -v, --version Show version number
104
111
  -h, --help Show this help message
105
112
  """
@@ -634,7 +641,7 @@ def fetch_file(filename, owner=None, repo=None, branch=None,
634
641
 
635
642
 
636
643
  def parse_version_tuple(v_str):
637
- """Parse version string like '1.2.5' into a comparable tuple of integers."""
644
+ """Parse version string like '1.2.7' into a comparable tuple of integers."""
638
645
  try:
639
646
  return tuple(int(x) for x in re.findall(r"\d+", v_str))
640
647
  except Exception:
@@ -665,22 +672,93 @@ def update_codefetch():
665
672
  return
666
673
 
667
674
  print(f"Update available: v{latest_version} (current: v{__version__})")
668
- print(f"Updating {package_name}...")
669
675
  else:
670
- print(f"Updating {package_name} to latest version...")
671
-
672
- cmd = [sys.executable, "-m", "pip", "install", "--upgrade", package_name]
673
- try:
674
- result = subprocess.run(cmd)
675
- if result.returncode == 0:
676
- target_v = f"v{latest_version}" if latest_version else "the latest version"
677
- print(f"\nSuccessfully updated CodeFetch to {target_v}!")
678
- else:
679
- 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}")
680
695
  print(f"You can manually update with: pip install --upgrade {package_name}")
681
- except Exception as e:
682
- print(f"\nError running update: {e}")
683
- 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}")
708
+ print(f"You can manually update with: pip install --upgrade {package_name}")
709
+
710
+
711
+ def uninstall_codefetch(yes=False):
712
+ """Uninstall codefetch-cli package from system."""
713
+ if not yes:
714
+ try:
715
+ choice = input("Are you sure you want to uninstall CodeFetch? [y/N]: ").strip().lower()
716
+ except (EOFError, KeyboardInterrupt):
717
+ print("\nCancelled.")
718
+ return
719
+
720
+ if choice not in ("y", "yes"):
721
+ print("Uninstall cancelled.")
722
+ return
723
+
724
+ # Clean up ~/.codefetch.json configuration file if present
725
+ if CONFIG_FILE.exists():
726
+ try:
727
+ CONFIG_FILE.unlink()
728
+ print(f"Removed configuration file: {CONFIG_FILE}")
729
+ except Exception:
730
+ pass
731
+
732
+ print("Uninstalling codefetch-cli...")
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}")
761
+ print("You can manually uninstall with: pip uninstall codefetch-cli")
684
762
 
685
763
 
686
764
  class CodefetchParser(argparse.ArgumentParser):
@@ -713,7 +791,9 @@ def build_parser():
713
791
  parser.add_argument("--set-default-user", type=str, help="Save default GitHub user")
714
792
  parser.add_argument("--config", action="store_true", help="Display active configuration")
715
793
  parser.add_argument("--reset-config", action="store_true", help="Reset configuration back to defaults")
716
- parser.add_argument("-U", "--update", action="store_true", help="Update CodeFetch to the latest version")
794
+ parser.add_argument("-U", "--update", action="store_true", help="Update CodeFetch to the latest version from PyPI")
795
+ parser.add_argument("--uninstall", action="store_true", help="Uninstall CodeFetch from your system")
796
+ parser.add_argument("-y", "--yes", action="store_true", help="Confirm uninstall without prompting")
717
797
  parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {__version__}")
718
798
  parser.add_argument("-h", "--help", action="help", help="Show help message")
719
799
 
@@ -788,6 +868,11 @@ def main():
788
868
  update_codefetch()
789
869
  return
790
870
 
871
+ # Handle --uninstall
872
+ if args.uninstall:
873
+ uninstall_codefetch(yes=args.yes)
874
+ return
875
+
791
876
  config = load_config()
792
877
  default_owner = config.get("owner", DEFAULT_OWNER)
793
878
  default_repo = config.get("repo", DEFAULT_REPO)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: codefetch-cli
3
- Version: 1.2.5
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
@@ -36,6 +36,7 @@ CodeFetch is a lightweight command-line utility and Python library designed to q
36
36
  - **Repository Discovery**: List all public repositories for any GitHub user with `--repos`.
37
37
  - **Tree Exploration**: List all supported code files within a repository with `--list`.
38
38
  - **Self-Updating**: Keep CodeFetch updated to the latest PyPI release with `codefetch --update`.
39
+ - **Clean Uninstall**: Easily remove CodeFetch and its configuration with `codefetch --uninstall`.
39
40
  - **Python Library Support**: Import and use programmatically with `import codefetch as cf`.
40
41
  - **Optional Persistent Defaults**: Save a default repository or user with `--set-default` if you frequently work with the same repository.
41
42
  - **Zero Runtime Dependencies**: Built using only the Python standard library with zero third-party dependencies.
@@ -130,11 +131,14 @@ codefetch --config
130
131
  codefetch --reset-config
131
132
  ```
132
133
 
133
- ### 5. Self-Updating
134
+ ### 5. Package Management
134
135
 
135
136
  ```bash
136
137
  # Update CodeFetch to the latest version published on PyPI
137
138
  codefetch --update
139
+
140
+ # Uninstall CodeFetch and remove local configuration
141
+ codefetch --uninstall
138
142
  ```
139
143
 
140
144
  ---
@@ -176,7 +180,8 @@ print(f"Found {len(files)} files")
176
180
  | `--set-default-user` | Set persistent default user | `codefetch --set-default-user username` |
177
181
  | `--config` | Display active configuration | `codefetch --config` |
178
182
  | `--reset-config` | Reset configuration back to defaults | `codefetch --reset-config` |
179
- | `-U`, `--update` | Update CodeFetch to latest PyPI version | `codefetch --update` |
183
+ | `-U`, `--update` | Update CodeFetch to latest PyPI release | `codefetch --update` |
184
+ | `--uninstall` | Uninstall CodeFetch from your system | `codefetch --uninstall` |
180
185
  | `-v`, `--version` | Display version information | `codefetch --version` |
181
186
  | `-h`, `--help` | Display help and usage message | `codefetch --help` |
182
187
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "codefetch-cli"
7
- version = "1.2.5"
7
+ version = "1.2.7"
8
8
  description = "Quickly fetch code files from GitHub repositories with simple commands"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -7,7 +7,7 @@ long_description = readme_path.read_text(encoding="utf-8") if readme_path.exists
7
7
 
8
8
  setup(
9
9
  name="codefetch-cli",
10
- version="1.2.5",
10
+ version="1.2.7",
11
11
  description="Quickly fetch code files from GitHub repositories with simple commands",
12
12
  long_description=long_description,
13
13
  long_description_content_type="text/markdown",
File without changes
File without changes