just-cli 0.1.0__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.
- just_cli-0.1.0/.github/workflows/publish.yml +37 -0
- just_cli-0.1.0/.gitignore +22 -0
- just_cli-0.1.0/PKG-INFO +107 -0
- just_cli-0.1.0/README.md +92 -0
- just_cli-0.1.0/pyproject.toml +28 -0
- just_cli-0.1.0/scripts/system/linux/proxy/proxy.sh +137 -0
- just_cli-0.1.0/scripts/system/windows/proxy/proxy.bat +56 -0
- just_cli-0.1.0/scripts/system/windows/proxy/proxy.ps1 +58 -0
- just_cli-0.1.0/src/just/__init__.py +40 -0
- just_cli-0.1.0/src/just/cli.py +79 -0
- just_cli-0.1.0/src/just/commands/__init__.py +0 -0
- just_cli-0.1.0/src/just/commands/download.py +62 -0
- just_cli-0.1.0/src/just/commands/edit.py +37 -0
- just_cli-0.1.0/src/just/commands/ext/__init__.py +7 -0
- just_cli-0.1.0/src/just/commands/ext/add.py +58 -0
- just_cli-0.1.0/src/just/commands/extract.py +76 -0
- just_cli-0.1.0/src/just/commands/install.py +36 -0
- just_cli-0.1.0/src/just/commands/linux.py +201 -0
- just_cli-0.1.0/src/just/commands/tunnel.py +27 -0
- just_cli-0.1.0/src/just/commands/view.py +33 -0
- just_cli-0.1.0/src/just/core/__init__.py +0 -0
- just_cli-0.1.0/src/just/core/config/__init__.py +34 -0
- just_cli-0.1.0/src/just/core/config/config.py +7 -0
- just_cli-0.1.0/src/just/core/config/utils.py +94 -0
- just_cli-0.1.0/src/just/core/extension/__init__.py +0 -0
- just_cli-0.1.0/src/just/core/extension/generator.py +405 -0
- just_cli-0.1.0/src/just/core/extension/parser.py +145 -0
- just_cli-0.1.0/src/just/core/extension/utils.py +145 -0
- just_cli-0.1.0/src/just/core/installer/__init__.py +10 -0
- just_cli-0.1.0/src/just/core/installer/binary.py +148 -0
- just_cli-0.1.0/src/just/core/installer/decorator.py +15 -0
- just_cli-0.1.0/src/just/core/installer/install_package.py +48 -0
- just_cli-0.1.0/src/just/core/installer/package_info.py +12 -0
- just_cli-0.1.0/src/just/core/installer/simple_release.py +296 -0
- just_cli-0.1.0/src/just/core/installer/source/__init__.py +17 -0
- just_cli-0.1.0/src/just/core/installer/source/base.py +22 -0
- just_cli-0.1.0/src/just/core/installer/source/http.py +103 -0
- just_cli-0.1.0/src/just/core/installer/source/local.py +54 -0
- just_cli-0.1.0/src/just/core/system_probe/__init__.py +15 -0
- just_cli-0.1.0/src/just/core/system_probe/system_info.py +101 -0
- just_cli-0.1.0/src/just/core/system_probe/system_probe.py +198 -0
- just_cli-0.1.0/src/just/installers/__init__.py +0 -0
- just_cli-0.1.0/src/just/installers/cloudflare/__init__.py +1 -0
- just_cli-0.1.0/src/just/installers/cloudflare/installer.py +14 -0
- just_cli-0.1.0/src/just/installers/edit/__init__.py +0 -0
- just_cli-0.1.0/src/just/installers/edit/installer.py +23 -0
- just_cli-0.1.0/src/just/tui/__init__.py +4 -0
- just_cli-0.1.0/src/just/tui/editor.py +111 -0
- just_cli-0.1.0/src/just/tui/extension.py +118 -0
- just_cli-0.1.0/src/just/tui/markdown.py +70 -0
- just_cli-0.1.0/src/just/utils/__init__.py +38 -0
- just_cli-0.1.0/src/just/utils/archive/__init__.py +22 -0
- just_cli-0.1.0/src/just/utils/archive/compression_handler.py +178 -0
- just_cli-0.1.0/src/just/utils/archive/extractor.py +87 -0
- just_cli-0.1.0/src/just/utils/archive/format_detect.py +199 -0
- just_cli-0.1.0/src/just/utils/archive/sevenzip_handler.py +44 -0
- just_cli-0.1.0/src/just/utils/archive/tar_handler.py +117 -0
- just_cli-0.1.0/src/just/utils/archive/zip_handler.py +81 -0
- just_cli-0.1.0/src/just/utils/download_utils.py +574 -0
- just_cli-0.1.0/src/just/utils/echo_utils.py +74 -0
- just_cli-0.1.0/src/just/utils/env_utils.py +164 -0
- just_cli-0.1.0/src/just/utils/file_utils.py +184 -0
- just_cli-0.1.0/src/just/utils/format_utils.py +9 -0
- just_cli-0.1.0/src/just/utils/progress.py +457 -0
- just_cli-0.1.0/src/just/utils/shell_utils.py +72 -0
- just_cli-0.1.0/src/just/utils/system_probe.py +214 -0
- just_cli-0.1.0/src/just/utils/typer_utils.py +35 -0
- just_cli-0.1.0/src/just/utils/user_interaction.py +4 -0
- just_cli-0.1.0/tests/Dockerfile +25 -0
- just_cli-0.1.0/tests/manual_test_download.py +454 -0
- just_cli-0.1.0/tests/run_tests.py +192 -0
- just_cli-0.1.0/tests/test_archive_extraction.py +345 -0
- just_cli-0.1.0/tests/test_extension.py +70 -0
- just_cli-0.1.0/tests/test_extension_generator.py +469 -0
- just_cli-0.1.0/tests/test_file_utils.py +369 -0
- just_cli-0.1.0/tests/test_init.py +175 -0
- just_cli-0.1.0/tests/test_installer.py +66 -0
- just_cli-0.1.0/tests/test_linux_commands.py +296 -0
- just_cli-0.1.0/tests/test_progress_utils.py +134 -0
- just_cli-0.1.0/tests/test_system_probe.py +123 -0
- just_cli-0.1.0/uv.lock +798 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build-and-publish:
|
|
13
|
+
name: Build and publish
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
permissions:
|
|
16
|
+
id-token: write
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout code
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Python
|
|
24
|
+
uses: actions/setup-python@v5
|
|
25
|
+
with:
|
|
26
|
+
python-version: "3.10"
|
|
27
|
+
|
|
28
|
+
- name: Install build tools
|
|
29
|
+
run: |
|
|
30
|
+
python -m pip install --upgrade pip
|
|
31
|
+
pip install build
|
|
32
|
+
|
|
33
|
+
- name: Build package
|
|
34
|
+
run: python -m build
|
|
35
|
+
|
|
36
|
+
- name: Publish to PyPI
|
|
37
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv
|
|
11
|
+
|
|
12
|
+
# IDE-specific files
|
|
13
|
+
.vscode
|
|
14
|
+
.idea
|
|
15
|
+
.claude
|
|
16
|
+
.qoder
|
|
17
|
+
|
|
18
|
+
# Environment configuration
|
|
19
|
+
.env
|
|
20
|
+
workspace/
|
|
21
|
+
extensions/
|
|
22
|
+
CLAUDE.md
|
just_cli-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: just-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Add your description here
|
|
5
|
+
Author-email: zzzcb <zjxs.zzzcb@gmail.com>
|
|
6
|
+
Requires-Python: >=3.10
|
|
7
|
+
Requires-Dist: httpx
|
|
8
|
+
Requires-Dist: py7zr
|
|
9
|
+
Requires-Dist: python-dotenv
|
|
10
|
+
Requires-Dist: rich>=14.2.0
|
|
11
|
+
Requires-Dist: textual>=6.4.0
|
|
12
|
+
Requires-Dist: typer>=0.20.0
|
|
13
|
+
Requires-Dist: zstandard
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# 🛠️ JUST CLI
|
|
17
|
+
|
|
18
|
+
## The simple stuff should be simple.
|
|
19
|
+
|
|
20
|
+
Sick of Googling *"how to install X on XXX"* for the 47th time, only to end up copying and pasting similar commands from various official docs?
|
|
21
|
+
|
|
22
|
+
Tired of copy-pasting giant commands and tapping arrow keys forever just to change one little thing?
|
|
23
|
+
|
|
24
|
+
Just want an all-in-one toolkit for everyday simple tasks, instead of endlessly searching and testing Deep Research results one by one?
|
|
25
|
+
|
|
26
|
+
## 📦 Installation
|
|
27
|
+
|
|
28
|
+
```shell
|
|
29
|
+
pip install just-cli
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🚀 The Good Stuff
|
|
33
|
+
|
|
34
|
+
### 1. The Toolkit
|
|
35
|
+
|
|
36
|
+
#### Download Files
|
|
37
|
+
```bash
|
|
38
|
+
# Download with resume support and custom headers
|
|
39
|
+
just download https://example.com/file.zip
|
|
40
|
+
just download https://example.com/file.zip -H "Authorization: Bearer token" -o myfile.zip
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### Extract Archives
|
|
44
|
+
```bash
|
|
45
|
+
# Automatic format detection - ZIP, TAR, GZ, BZ2, XZ, ZSTD, 7Z
|
|
46
|
+
just extract archive.tar.gz
|
|
47
|
+
just extract data.7z -o out/
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### Edit Files
|
|
51
|
+
```bash
|
|
52
|
+
# Beautiful TUI editor
|
|
53
|
+
just edit README.md
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
#### View Files
|
|
57
|
+
```bash
|
|
58
|
+
# Preview markdown with syntax highlighting
|
|
59
|
+
just view README.md
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
#### Linux Commands (for Windows users)
|
|
63
|
+
```bash
|
|
64
|
+
just ls
|
|
65
|
+
just cat
|
|
66
|
+
just mkdir
|
|
67
|
+
just cp
|
|
68
|
+
just mv
|
|
69
|
+
just rm
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 2. The Extension System
|
|
73
|
+
|
|
74
|
+
This is where the magic happens. You can turn *any* complex shell command into a beautiful, typed `just` command.
|
|
75
|
+
|
|
76
|
+
Imagine you have a command you use all the time, like checking a Docker container's IP:
|
|
77
|
+
```bash
|
|
78
|
+
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' f523e75ca4ef
|
|
79
|
+
```
|
|
80
|
+
*Gross.*
|
|
81
|
+
|
|
82
|
+
Now, wave your wand:
|
|
83
|
+
```bash
|
|
84
|
+
just ext add docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' f523e75ca4ef
|
|
85
|
+
> just docker ip f523e75ca4ef[container_id:str#The container ID]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Now you have a new command:
|
|
89
|
+
```bash
|
|
90
|
+
just docker ip my-container
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
It even generates help messages!
|
|
94
|
+
```bash
|
|
95
|
+
just docker ip --help
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 🤝 Contributing
|
|
99
|
+
|
|
100
|
+
Found a bug? Want to add a new installer?
|
|
101
|
+
Fork it, fix it, ship it. We love PRs.
|
|
102
|
+
Just keep it cool, keep it simple, and don't break the "just works" vibe.
|
|
103
|
+
|
|
104
|
+
## 📄 License
|
|
105
|
+
|
|
106
|
+
MIT. Go wild.
|
|
107
|
+
|
just_cli-0.1.0/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# 🛠️ JUST CLI
|
|
2
|
+
|
|
3
|
+
## The simple stuff should be simple.
|
|
4
|
+
|
|
5
|
+
Sick of Googling *"how to install X on XXX"* for the 47th time, only to end up copying and pasting similar commands from various official docs?
|
|
6
|
+
|
|
7
|
+
Tired of copy-pasting giant commands and tapping arrow keys forever just to change one little thing?
|
|
8
|
+
|
|
9
|
+
Just want an all-in-one toolkit for everyday simple tasks, instead of endlessly searching and testing Deep Research results one by one?
|
|
10
|
+
|
|
11
|
+
## 📦 Installation
|
|
12
|
+
|
|
13
|
+
```shell
|
|
14
|
+
pip install just-cli
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 🚀 The Good Stuff
|
|
18
|
+
|
|
19
|
+
### 1. The Toolkit
|
|
20
|
+
|
|
21
|
+
#### Download Files
|
|
22
|
+
```bash
|
|
23
|
+
# Download with resume support and custom headers
|
|
24
|
+
just download https://example.com/file.zip
|
|
25
|
+
just download https://example.com/file.zip -H "Authorization: Bearer token" -o myfile.zip
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
#### Extract Archives
|
|
29
|
+
```bash
|
|
30
|
+
# Automatic format detection - ZIP, TAR, GZ, BZ2, XZ, ZSTD, 7Z
|
|
31
|
+
just extract archive.tar.gz
|
|
32
|
+
just extract data.7z -o out/
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### Edit Files
|
|
36
|
+
```bash
|
|
37
|
+
# Beautiful TUI editor
|
|
38
|
+
just edit README.md
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
#### View Files
|
|
42
|
+
```bash
|
|
43
|
+
# Preview markdown with syntax highlighting
|
|
44
|
+
just view README.md
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### Linux Commands (for Windows users)
|
|
48
|
+
```bash
|
|
49
|
+
just ls
|
|
50
|
+
just cat
|
|
51
|
+
just mkdir
|
|
52
|
+
just cp
|
|
53
|
+
just mv
|
|
54
|
+
just rm
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 2. The Extension System
|
|
58
|
+
|
|
59
|
+
This is where the magic happens. You can turn *any* complex shell command into a beautiful, typed `just` command.
|
|
60
|
+
|
|
61
|
+
Imagine you have a command you use all the time, like checking a Docker container's IP:
|
|
62
|
+
```bash
|
|
63
|
+
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' f523e75ca4ef
|
|
64
|
+
```
|
|
65
|
+
*Gross.*
|
|
66
|
+
|
|
67
|
+
Now, wave your wand:
|
|
68
|
+
```bash
|
|
69
|
+
just ext add docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' f523e75ca4ef
|
|
70
|
+
> just docker ip f523e75ca4ef[container_id:str#The container ID]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Now you have a new command:
|
|
74
|
+
```bash
|
|
75
|
+
just docker ip my-container
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
It even generates help messages!
|
|
79
|
+
```bash
|
|
80
|
+
just docker ip --help
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## 🤝 Contributing
|
|
84
|
+
|
|
85
|
+
Found a bug? Want to add a new installer?
|
|
86
|
+
Fork it, fix it, ship it. We love PRs.
|
|
87
|
+
Just keep it cool, keep it simple, and don't break the "just works" vibe.
|
|
88
|
+
|
|
89
|
+
## 📄 License
|
|
90
|
+
|
|
91
|
+
MIT. Go wild.
|
|
92
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "just-cli"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Add your description here"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "zzzcb", email = "zjxs.zzzcb@gmail.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.10"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"httpx",
|
|
12
|
+
"python-dotenv",
|
|
13
|
+
"py7zr",
|
|
14
|
+
"rich>=14.2.0",
|
|
15
|
+
"textual>=6.4.0",
|
|
16
|
+
"typer>=0.20.0",
|
|
17
|
+
"zstandard",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
just = "just.cli:main"
|
|
22
|
+
|
|
23
|
+
[build-system]
|
|
24
|
+
requires = ["hatchling"]
|
|
25
|
+
build-backend = "hatchling.build"
|
|
26
|
+
|
|
27
|
+
[tool.hatch.build.targets.wheel]
|
|
28
|
+
packages = ["src/just"]
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Proxy Control Functions
|
|
4
|
+
# Source this file to use: source proxy.sh
|
|
5
|
+
# Or install to ~/.bashrc for permanent availability
|
|
6
|
+
|
|
7
|
+
# Set proxy variables from environment or use default
|
|
8
|
+
HTTP_PROXY_URL=${HTTP_PROXY_URL:-"http://127.0.0.1:7890"}
|
|
9
|
+
HTTPS_PROXY_URL=${HTTPS_PROXY_URL:-$HTTP_PROXY_URL}
|
|
10
|
+
|
|
11
|
+
# Proxy control function
|
|
12
|
+
proxy() {
|
|
13
|
+
case "${1,,}" in
|
|
14
|
+
on)
|
|
15
|
+
export HTTP_PROXY=$HTTP_PROXY_URL
|
|
16
|
+
export HTTPS_PROXY=$HTTPS_PROXY_URL
|
|
17
|
+
export http_proxy=$HTTP_PROXY_URL
|
|
18
|
+
export https_proxy=$HTTPS_PROXY_URL
|
|
19
|
+
echo -e "\033[32m[ON]\033[0m HTTP Proxy $HTTP_PROXY enabled in Bash"
|
|
20
|
+
echo -e "\033[32m[ON]\033[0m HTTPS Proxy $HTTPS_PROXY enabled in Bash"
|
|
21
|
+
;;
|
|
22
|
+
off)
|
|
23
|
+
if [[ -n "$HTTP_PROXY" ]]; then
|
|
24
|
+
echo -e "\033[31m[OFF]\033[0m HTTP Proxy $HTTP_PROXY disabled in Bash"
|
|
25
|
+
echo -e "\033[31m[OFF]\033[0m HTTPS Proxy $HTTPS_PROXY disabled in Bash"
|
|
26
|
+
else
|
|
27
|
+
echo -e "\033[31m[OFF]\033[0m Proxy disabled in Bash"
|
|
28
|
+
fi
|
|
29
|
+
unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy
|
|
30
|
+
;;
|
|
31
|
+
uninstall)
|
|
32
|
+
uninstall_proxy
|
|
33
|
+
;;
|
|
34
|
+
-h|h|help|"")
|
|
35
|
+
echo
|
|
36
|
+
echo "Proxy Control Function"
|
|
37
|
+
echo "=========================================="
|
|
38
|
+
echo "Usage:"
|
|
39
|
+
echo " proxy on - Enable proxy"
|
|
40
|
+
echo " proxy off - Disable proxy"
|
|
41
|
+
echo " proxy uninstall - Uninstall CLI"
|
|
42
|
+
echo
|
|
43
|
+
echo "Current HTTP_PROXY : $HTTP_PROXY_URL"
|
|
44
|
+
echo "Current HTTPS_PROXY: $HTTPS_PROXY_URL"
|
|
45
|
+
echo "=========================================="
|
|
46
|
+
;;
|
|
47
|
+
install)
|
|
48
|
+
echo -e "\033[31m[ERROR]\033[0m Use 'bash proxy.sh install' instead"
|
|
49
|
+
;;
|
|
50
|
+
*)
|
|
51
|
+
echo "Invalid argument: $1"
|
|
52
|
+
echo
|
|
53
|
+
echo "Usage: proxy [on|off|uninstall|-h]"
|
|
54
|
+
;;
|
|
55
|
+
esac
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
install_proxy() {
|
|
59
|
+
local bashrc="$HOME/.bashrc"
|
|
60
|
+
|
|
61
|
+
# Get absolute path in a more compatible way
|
|
62
|
+
local script_path="$0"
|
|
63
|
+
if [[ "$script_path" != /* ]]; then
|
|
64
|
+
script_path="$(pwd)/$script_path"
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
# Normalize path to remove ./ components
|
|
68
|
+
script_path="${script_path//\/.\//\/}"
|
|
69
|
+
|
|
70
|
+
# Check if already installed
|
|
71
|
+
if grep -q "# Proxy Control Functions - Installed by proxy.sh" "$bashrc" 2>/dev/null; then
|
|
72
|
+
echo -e "\033[33m[WARN]\033[0m Proxy already installed in $bashrc"
|
|
73
|
+
return 1
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
# Add installation marker and source command
|
|
77
|
+
echo "" >> "$bashrc"
|
|
78
|
+
echo "# Proxy Control Functions - Installed by proxy.sh" >> "$bashrc"
|
|
79
|
+
echo "source \"$script_path\"" >> "$bashrc"
|
|
80
|
+
echo "# End of Proxy Control Functions" >> "$bashrc"
|
|
81
|
+
|
|
82
|
+
echo -e "\033[32m[OK]\033[0m Proxy installed to $bashrc"
|
|
83
|
+
echo "Restart your terminal or run: source ~/.bashrc"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
uninstall_proxy() {
|
|
87
|
+
local bashrc="$HOME/.bashrc"
|
|
88
|
+
|
|
89
|
+
# Check if installed
|
|
90
|
+
if ! grep -q "# Proxy Control Functions - Installed by proxy.sh" "$bashrc" 2>/dev/null; then
|
|
91
|
+
echo -e "\033[33m[WARN]\033[0m Proxy not found in $bashrc"
|
|
92
|
+
return 1
|
|
93
|
+
fi
|
|
94
|
+
|
|
95
|
+
# Remove installation
|
|
96
|
+
sed -i '/# Proxy Control Functions - Installed by proxy.sh/,/# End of Proxy Control Functions/d' "$bashrc"
|
|
97
|
+
|
|
98
|
+
echo -e "\033[32m[OK]\033[0m Proxy uninstalled from $bashrc"
|
|
99
|
+
echo "Restart your terminal or run: source ~/.bashrc"
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
# Show help when script is executed without arguments
|
|
103
|
+
show_script_help() {
|
|
104
|
+
echo
|
|
105
|
+
echo "Proxy Control Script"
|
|
106
|
+
echo "=========================================="
|
|
107
|
+
echo "Usage:"
|
|
108
|
+
echo " bash proxy.sh install - Install CLI"
|
|
109
|
+
echo " bash proxy.sh uninstall - Uninstall CLI"
|
|
110
|
+
echo
|
|
111
|
+
echo "Current HTTP_PROXY : $HTTP_PROXY_URL"
|
|
112
|
+
echo "Current HTTPS_PROXY: $HTTPS_PROXY_URL"
|
|
113
|
+
echo "=========================================="
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# Main execution logic
|
|
117
|
+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
118
|
+
# Script is being executed directly
|
|
119
|
+
case "${1,,}" in
|
|
120
|
+
install)
|
|
121
|
+
install_proxy
|
|
122
|
+
;;
|
|
123
|
+
uninstall)
|
|
124
|
+
uninstall_proxy
|
|
125
|
+
;;
|
|
126
|
+
-h|h|help|"")
|
|
127
|
+
show_script_help
|
|
128
|
+
;;
|
|
129
|
+
*)
|
|
130
|
+
proxy "$@"
|
|
131
|
+
;;
|
|
132
|
+
esac
|
|
133
|
+
else
|
|
134
|
+
# Script is being sourced
|
|
135
|
+
# Only define the proxy function, not install/uninstall
|
|
136
|
+
:
|
|
137
|
+
fi
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
|
+
:: Set proxy variables from environment or use default
|
|
4
|
+
if defined HTTP_PROXY_URL (
|
|
5
|
+
set HTTP_PROXY_URL=%HTTP_PROXY_URL%
|
|
6
|
+
) else (
|
|
7
|
+
set HTTP_PROXY_URL=http://127.0.0.1:7890
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
if defined HTTPS_PROXY_URL (
|
|
11
|
+
set HTTPS_PROXY_URL=%HTTPS_PROXY_URL%
|
|
12
|
+
) else (
|
|
13
|
+
set HTTPS_PROXY_URL=%HTTP_PROXY_URL%
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
if /i "%1"=="on" (
|
|
17
|
+
call :EnableProxy
|
|
18
|
+
) else if /i "%1"=="off" (
|
|
19
|
+
call :DisableProxy
|
|
20
|
+
) else (
|
|
21
|
+
call :ShowHelp
|
|
22
|
+
exit /b 0
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
exit /b 0
|
|
26
|
+
|
|
27
|
+
:ShowHelp
|
|
28
|
+
echo.
|
|
29
|
+
echo Proxy Control Script
|
|
30
|
+
echo ==========================================
|
|
31
|
+
echo Usage:
|
|
32
|
+
echo %~nx0 on - Enable proxy
|
|
33
|
+
echo %~nx0 off - Disable proxy
|
|
34
|
+
echo.
|
|
35
|
+
echo Current HTTP_PROXY : %HTTP_PROXY_URL%
|
|
36
|
+
echo Current HTTPS_PROXY: %HTTPS_PROXY_URL%
|
|
37
|
+
echo ==========================================
|
|
38
|
+
exit /b 0
|
|
39
|
+
|
|
40
|
+
:EnableProxy
|
|
41
|
+
set HTTP_PROXY=%HTTP_PROXY_URL%
|
|
42
|
+
set HTTPS_PROXY=%HTTPS_PROXY_URL%
|
|
43
|
+
echo [92m[ON][0m HTTP Proxy %HTTP_PROXY% enabled in CMD
|
|
44
|
+
echo [92m[ON][0m HTTPS Proxy %HTTPS_PROXY% enabled in CMD
|
|
45
|
+
exit /b 0
|
|
46
|
+
|
|
47
|
+
:DisableProxy
|
|
48
|
+
if defined HTTP_PROXY (
|
|
49
|
+
echo [91m[OFF][0m HTTP Proxy %HTTP_PROXY% disabled in CMD
|
|
50
|
+
echo [91m[OFF][0m HTTPS Proxy %HTTPS_PROXY% disabled in CMD
|
|
51
|
+
set HTTP_PROXY=
|
|
52
|
+
set HTTPS_PROXY=
|
|
53
|
+
) else (
|
|
54
|
+
echo [91m[OFF][0m Proxy disabled in CMD
|
|
55
|
+
)
|
|
56
|
+
exit /b 0
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Parse command line arguments manually to handle -h properly
|
|
2
|
+
$Action = $args[0]
|
|
3
|
+
|
|
4
|
+
# Set proxy variables from environment or use default
|
|
5
|
+
$HTTP_PROXY_URL = if ($env:HTTP_PROXY_URL) { $env:HTTP_PROXY_URL } else { "http://127.0.0.1:7890" }
|
|
6
|
+
$HTTPS_PROXY_URL = if ($env:HTTPS_PROXY_URL) { $env:HTTPS_PROXY_URL } else { $HTTP_PROXY_URL }
|
|
7
|
+
|
|
8
|
+
function Show-Help {
|
|
9
|
+
Write-Host ""
|
|
10
|
+
Write-Host "Proxy Control Script"
|
|
11
|
+
Write-Host "=========================================="
|
|
12
|
+
Write-Host "Usage:"
|
|
13
|
+
Write-Host " proxy.ps1 on - Enable proxy"
|
|
14
|
+
Write-Host " proxy.ps1 off - Disable proxy"
|
|
15
|
+
Write-Host ""
|
|
16
|
+
Write-Host "Current HTTP_PROXY : $HTTP_PROXY_URL"
|
|
17
|
+
Write-Host "Current HTTPS_PROXY: $HTTPS_PROXY_URL"
|
|
18
|
+
Write-Host "=========================================="
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function Enable-Proxy {
|
|
22
|
+
$env:HTTP_PROXY = $HTTP_PROXY_URL
|
|
23
|
+
$env:HTTPS_PROXY = $HTTPS_PROXY_URL
|
|
24
|
+
Write-Host "[ON]" -ForegroundColor Green -NoNewline
|
|
25
|
+
Write-Host " HTTP Proxy $env:HTTP_PROXY enabled in PowerShell"
|
|
26
|
+
Write-Host "[ON]" -ForegroundColor Green -NoNewline
|
|
27
|
+
Write-Host " HTTPS Proxy $env:HTTPS_PROXY enabled in PowerShell"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function Disable-Proxy {
|
|
31
|
+
$currentProxy = $env:HTTP_PROXY
|
|
32
|
+
if ($currentProxy) {
|
|
33
|
+
Write-Host "[OFF]" -ForegroundColor Red -NoNewline
|
|
34
|
+
Write-Host " HTTP Proxy $env:HTTP_PROXY disabled in PowerShell"
|
|
35
|
+
Write-Host "[OFF]" -ForegroundColor Red -NoNewline
|
|
36
|
+
Write-Host " HTTPS Proxy $env:HTTPS_PROXY disabled in PowerShell"
|
|
37
|
+
} else {
|
|
38
|
+
Write-Host "[OFF]" -ForegroundColor Red -NoNewline
|
|
39
|
+
Write-Host " Proxy disabled in PowerShell"
|
|
40
|
+
}
|
|
41
|
+
Remove-Item Env:HTTP_PROXY -ErrorAction SilentlyContinue
|
|
42
|
+
Remove-Item Env:HTTPS_PROXY -ErrorAction SilentlyContinue
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# Main logic
|
|
46
|
+
if (-not $Action -or $Action -eq "" -or $Action -eq "-h" -or $Action -eq "h" -or $Action -eq "help") {
|
|
47
|
+
Show-Help
|
|
48
|
+
} else {
|
|
49
|
+
switch ($Action) {
|
|
50
|
+
"on" { Enable-Proxy }
|
|
51
|
+
"off" { Disable-Proxy }
|
|
52
|
+
default {
|
|
53
|
+
Write-Host "Invalid argument: $Action"
|
|
54
|
+
Write-Host ""
|
|
55
|
+
Show-Help
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from typing_extensions import Annotated
|
|
2
|
+
from typer import Option, Argument
|
|
3
|
+
|
|
4
|
+
from just.cli import just_cli,capture_exception
|
|
5
|
+
from just.core.config import JustConfig, load_env_config, update_env_config, get_cache_dir
|
|
6
|
+
from just.core.installer import installer, SimpleReleaseInstaller, BinaryInstaller
|
|
7
|
+
from just.utils import (
|
|
8
|
+
SystemProbe,
|
|
9
|
+
create_typer_app,
|
|
10
|
+
confirm_action,
|
|
11
|
+
docstring,
|
|
12
|
+
download_with_resume,
|
|
13
|
+
echo,
|
|
14
|
+
extract,
|
|
15
|
+
execute_commands
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
config = JustConfig()
|
|
20
|
+
system = SystemProbe()
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"Annotated",
|
|
24
|
+
"Argument",
|
|
25
|
+
"Option",
|
|
26
|
+
"capture_exception",
|
|
27
|
+
"create_typer_app",
|
|
28
|
+
"docstring",
|
|
29
|
+
"echo",
|
|
30
|
+
"extract",
|
|
31
|
+
"execute_commands",
|
|
32
|
+
"config",
|
|
33
|
+
"just_cli",
|
|
34
|
+
"installer",
|
|
35
|
+
"SimpleReleaseInstaller",
|
|
36
|
+
"BinaryInstaller",
|
|
37
|
+
"load_env_config",
|
|
38
|
+
"update_env_config",
|
|
39
|
+
"system"
|
|
40
|
+
]
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import functools
|
|
2
|
+
import importlib
|
|
3
|
+
import os
|
|
4
|
+
import traceback
|
|
5
|
+
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typer.core import TyperGroup
|
|
8
|
+
from typing import Any, Callable, List, TypeVar, Optional
|
|
9
|
+
|
|
10
|
+
from just.core.config import load_env_config, get_command_dir, get_extension_dir
|
|
11
|
+
from just.utils import echo
|
|
12
|
+
from just.utils.typer_utils import create_typer_app
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
just_cli = create_typer_app()
|
|
16
|
+
|
|
17
|
+
T = TypeVar('T')
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def capture_exception(func: Callable[..., T]) -> Callable[..., Optional[T]]:
|
|
21
|
+
@functools.wraps(func)
|
|
22
|
+
def wrapper(*args: Any, **kwargs: Any) -> Optional[T]:
|
|
23
|
+
try:
|
|
24
|
+
return func(*args, **kwargs)
|
|
25
|
+
except Exception as e:
|
|
26
|
+
echo.error(str(e))
|
|
27
|
+
exit(1)
|
|
28
|
+
|
|
29
|
+
return wrapper
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SortedGroup(TyperGroup):
|
|
33
|
+
def list_commands(self, ctx):
|
|
34
|
+
return sorted(super().list_commands(ctx))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def run_just_cli(*args, **kwargs):
|
|
38
|
+
load_env_config()
|
|
39
|
+
just_cli(*args, **kwargs)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def traverse_script_dir(directory: str) -> List[str]:
|
|
43
|
+
script_modules = []
|
|
44
|
+
for root, dirs, files in os.walk(directory):
|
|
45
|
+
for file in files:
|
|
46
|
+
if not file.startswith('_') and file.endswith(".py"):
|
|
47
|
+
script_modules.append(
|
|
48
|
+
"just." +
|
|
49
|
+
'.'.join(Path(root).relative_to(Path(__file__).parent).parts) +
|
|
50
|
+
f".{str(Path(file).stem)}"
|
|
51
|
+
)
|
|
52
|
+
return script_modules
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def main():
|
|
57
|
+
# Dynamically import all script modules to register their commands
|
|
58
|
+
script_modules = []
|
|
59
|
+
script_modules.extend(traverse_script_dir(get_command_dir().as_posix()))
|
|
60
|
+
script_modules.extend(traverse_script_dir(get_extension_dir().as_posix()))
|
|
61
|
+
script_modules.sort()
|
|
62
|
+
missing_packages = []
|
|
63
|
+
for module_name in script_modules:
|
|
64
|
+
try:
|
|
65
|
+
# echo.debug("Importing", module_name)
|
|
66
|
+
importlib.import_module(module_name)
|
|
67
|
+
except ImportError as e:
|
|
68
|
+
traceback.print_exc()
|
|
69
|
+
package_name = e.name
|
|
70
|
+
if package_name not in missing_packages:
|
|
71
|
+
missing_packages.append(package_name)
|
|
72
|
+
# Handle the case where the module cannot be found
|
|
73
|
+
echo.warning(
|
|
74
|
+
f"`{package_name}` is not installed, some sub commands are disabled, "
|
|
75
|
+
f"refer to README.md for instructions."
|
|
76
|
+
)
|
|
77
|
+
continue
|
|
78
|
+
# Run the CLI application
|
|
79
|
+
run_just_cli()
|
|
File without changes
|