binmanx 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.
binmanx-1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dxvampi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
binmanx-1.0/PKG-INFO ADDED
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: binmanx
3
+ Version: 1.0
4
+ Summary: A simple binary version manager wrapper
5
+ License: MIT License
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: POSIX :: Linux
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Dynamic: license-file
12
+
13
+ # binman
14
+ This Python CLI utility allows you to manage binaries with different versions in an easier way
binmanx-1.0/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # binman
2
+ This Python CLI utility allows you to manage binaries with different versions in an easier way
@@ -0,0 +1,21 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "binmanx"
7
+ version = "1.0"
8
+ description = "A simple binary version manager wrapper"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT License"}
12
+ classifiers = [
13
+ "Programming Language :: Python :: 3",
14
+ "Operating System :: POSIX :: Linux",
15
+ ]
16
+
17
+ [project.scripts]
18
+ binman = "binman.main:main"
19
+
20
+ [tool.setuptools.packages.find]
21
+ where = ["src"]
binmanx-1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,29 @@
1
+ import json
2
+ from pathlib import Path
3
+ from typing import Dict
4
+ from binman.models import Binary
5
+
6
+ class ConfigManager:
7
+ def __init__(self):
8
+ self.config_dir = Path.home() / ".config" / "binman"
9
+ self.config_file = self.config_dir / "config.json"
10
+
11
+ def load_binaries(self) -> Dict[str, Binary]:
12
+ """Reads the JSON and return a dictionary of Binary objects"""
13
+ if not self.config_file.exists():
14
+ return {}
15
+ try:
16
+ with open(self.config_file, "r", encoding="utf-8") as f:
17
+ data = json.load(f)
18
+
19
+ return {alias: Binary.from_dict(info) for alias, info in data.items()}
20
+ except Exception:
21
+ return {}
22
+
23
+ def save_binaries(self, binaries: Dict[str, Binary]) -> None:
24
+ self.config_dir.mkdir(parents=True, exist_ok=True)
25
+
26
+ raw_data = {alias: binary.to_dict() for alias, binary in binaries.items()}
27
+
28
+ with open(self.config_file, "w", encoding="utf-8") as f:
29
+ json.dump(raw_data, f, indent=2)
@@ -0,0 +1,19 @@
1
+ import os
2
+ import sys
3
+ from typing import List, Optional
4
+ from binman.models import Binary
5
+
6
+ class Executor:
7
+ def __init__(self, binary: Binary, args: Optional[List[str]] = None):
8
+ self.binary = binary
9
+ # If no args are passed, empty list is returned
10
+ self.args = args if args is not None else []
11
+
12
+ def execute(self) -> None:
13
+ """Replaces actual process with binary."""
14
+ if not self.binary.exists():
15
+ print(f"❌ Error: Binary for '{self.binary.alias}' does not exist in: {self.binary.path}")
16
+ sys.exit(1)
17
+
18
+ # os.execv requires: (bin_path, [process_name, arg1, arg2, ...])
19
+ os.execv(self.binary.path, [self.binary.path] + self.args)
@@ -0,0 +1,82 @@
1
+ import sys
2
+ from binman.config import ConfigManager
3
+ from binman.models import Binary
4
+ from binman.executor import Executor
5
+
6
+
7
+ class BinmanCLI:
8
+ def __init__(self):
9
+ self.config_manager = ConfigManager()
10
+
11
+ def run_config(self) -> None:
12
+ print("--- Binman Configuration ---")
13
+ binaries = self.config_manager.load_binaries()
14
+
15
+ while True:
16
+ route = input("Specify route: ").strip()
17
+ codename = input("Codename: ").strip()
18
+
19
+ if route and codename:
20
+ # Creates object using custom Binary class
21
+ binaries[codename] = Binary(alias=codename, path=route)
22
+ else:
23
+ print("Route and codename/alias can not be empty.")
24
+ continue
25
+
26
+ while True:
27
+ again = input("Want to add another binary [y/N]: ").strip().lower()
28
+
29
+ if again == "":
30
+ again = "n"
31
+
32
+ if again == "y" or again == "n":
33
+ break
34
+
35
+ print(f"Unexpected argument ({again}). Please enter 'y' or 'n'.")
36
+
37
+ if again == "n":
38
+ break
39
+
40
+ self.config_manager.save_binaries(binaries)
41
+ print("\nConfiguration saved!")
42
+ for name, binary in binaries.items():
43
+ print(f"{name} ({binary.path}) is ready to use! (binman -b {name} args)")
44
+
45
+ def run_execution(self, args: list) -> None:
46
+ if "-b" not in args:
47
+ print("Error: Missing binary alias. Use: binman -b <codename> [args]")
48
+ print("Or configure new binaries using: binman config")
49
+ sys.exit(1)
50
+
51
+ try:
52
+ b_index = args.index("-b")
53
+ codename = args[b_index + 1]
54
+ except IndexError:
55
+ print("Error: You must specify a codename after -b")
56
+ sys.exit(1)
57
+
58
+ binaries = self.config_manager.load_binaries()
59
+ if codename not in binaries:
60
+ print(f"Error: Codename '{codename}' not found. Run 'binman config' first.")
61
+ sys.exit(1)
62
+
63
+ target_binary = binaries[codename]
64
+
65
+ bin_args = args[:b_index] + args[b_index + 2:]
66
+
67
+ executor = Executor(binary=target_binary, args=bin_args)
68
+ executor.execute()
69
+
70
+
71
+ def main():
72
+ cli = BinmanCLI()
73
+ args = sys.argv[1:]
74
+
75
+ if len(args) > 0 and args[0] == "config":
76
+ cli.run_config()
77
+ else:
78
+ cli.run_execution(args)
79
+
80
+
81
+ if __name__ == "__main__":
82
+ main()
@@ -0,0 +1,20 @@
1
+ from dataclasses import dataclass
2
+ from pathlib import Path
3
+
4
+ @dataclass
5
+ class Binary:
6
+ alias: str
7
+ path: str
8
+
9
+ def exists(self) -> bool:
10
+ """Checks if the binary exists"""
11
+ return Path(self.path).exists()
12
+
13
+ def to_dict(self) -> dict:
14
+ """Turns the object to a dict to save on the JSON"""
15
+ return {"alias": self.alias, "path": self.path}
16
+
17
+ @classmethod
18
+ def from_dict(cls, data: dict) -> 'Binary':
19
+ """Makes anf instance of Binary from a dictionary"""
20
+ return cls(alias=data["alias"], path = data["path"])
@@ -0,0 +1,14 @@
1
+ Metadata-Version: 2.4
2
+ Name: binmanx
3
+ Version: 1.0
4
+ Summary: A simple binary version manager wrapper
5
+ License: MIT License
6
+ Classifier: Programming Language :: Python :: 3
7
+ Classifier: Operating System :: POSIX :: Linux
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Dynamic: license-file
12
+
13
+ # binman
14
+ This Python CLI utility allows you to manage binaries with different versions in an easier way
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/binman/__init__.py
5
+ src/binman/config.py
6
+ src/binman/executor.py
7
+ src/binman/main.py
8
+ src/binman/models.py
9
+ src/binmanx.egg-info/PKG-INFO
10
+ src/binmanx.egg-info/SOURCES.txt
11
+ src/binmanx.egg-info/dependency_links.txt
12
+ src/binmanx.egg-info/entry_points.txt
13
+ src/binmanx.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ binman = binman.main:main
@@ -0,0 +1 @@
1
+ binman