Skip to content

Commit

Permalink
package manager backend & CLI + bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
ImShyMike committed Jan 7, 2025
1 parent 92d394c commit a521e45
Show file tree
Hide file tree
Showing 11 changed files with 688 additions and 39 deletions.
2 changes: 1 addition & 1 deletion eryx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version of the package."""

CURRENT_VERSION = "0.2.11"
CURRENT_VERSION = "0.3.0"
77 changes: 72 additions & 5 deletions eryx/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@
from colorama import init

from eryx.__init__ import CURRENT_VERSION
from eryx.packages.packages import (
delete_package,
install,
list_packages,
uninstall,
upload_package,
)
from eryx.runtime.repl import start_repl
from eryx.runtime.runner import run_code
from eryx.server.ide import start_ide
from eryx.packages.packages import DEFAULT_SERVER

init(autoreset=True)
current_path = os.path.dirname(os.path.abspath(__file__))
Expand Down Expand Up @@ -65,15 +73,58 @@ def main():

# 'server' command
server_parser = subparsers.add_parser("server", help="Start the web IDE")
server_parser.add_argument("--port", type=int, help="Port number for the web IDE.")
server_parser.add_argument("--host", type=str, help="Host for the web IDE.")
server_parser.add_argument(
"--no-file-io", action="store_true", help="Disable file I/O"
"--port", type=int, help="Port number for the web IDE.", default=80
)
server_parser.add_argument(
"--host", type=str, help="Host for the web IDE.", default="0.0.0.0"
)
server_parser.add_argument(
"--no-file-io", action="store_true", help="Disable file I/O", default=False
)

# 'test' command
subparsers.add_parser("test", help="Run the test suite")

package_parser = subparsers.add_parser("package", help="Manage Eryx packages")
package_subparsers = package_parser.add_subparsers(
dest="package_command", help="Available package commands"
)
install_parser = package_subparsers.add_parser("install", help="Install a package")
install_parser.add_argument("package", type=str, help="Package to install")
install_parser.add_argument(
"--upgrade", action="store_true", help="Upgrade package", default=False
)
install_parser.add_argument(
"--server",
type=str,
help="Server to use",
default=DEFAULT_SERVER,
)

uninstall_parser = package_subparsers.add_parser("uninstall", help="Uninstall a package")
uninstall_parser.add_argument("package", type=str, help="Package to uninstall")

package_subparsers.add_parser("list", help="List all installed packages")

upload_parser = package_subparsers.add_parser("upload", help="Upload a package")
upload_parser.add_argument("package_folder", type=str, help="Package folder to upload")
upload_parser.add_argument(
"--server",
type=str,
help="Server to use",
default=DEFAULT_SERVER,
)

delete_parser = package_subparsers.add_parser("delete", help="Delete a package")
delete_parser.add_argument("package", type=str, help="Package to delete")
delete_parser.add_argument(
"--server",
type=str,
help="Server to use",
default=DEFAULT_SERVER,
)

# Parse the arguments
args = arg_parser.parse_args()

Expand All @@ -96,12 +147,28 @@ def main():
)
elif args.command == "server":
start_ide(
args.host or "0.0.0.0",
port=args.port or 80,
args.host,
port=args.port,
disable_file_io=args.no_file_io,
)
elif args.command == "test":
pytest.main(["-v", os.path.join(current_path, "tests", "run_tests.py")])
elif args.command == "package":
try:
if args.package_command == "install":
install(args.package, args.server, args.upgrade)
elif args.package_command == "uninstall":
uninstall(args.package)
elif args.package_command == "list":
list_packages()
elif args.package_command == "upload":
upload_package(args.package_folder, args.server)
elif args.package_command == "delete":
delete_package(args.package, args.server)
else:
package_parser.print_help()
except KeyboardInterrupt:
print("\nOperation cancelled.")
elif args.command is None:
arg_parser.print_help()
else:
Expand Down
Empty file added eryx/packages/__init__.py
Empty file.
1 change: 1 addition & 0 deletions eryx/packages/packages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading

0 comments on commit a521e45

Please sign in to comment.