diff --git a/pyproject.toml b/pyproject.toml index 9cdf351a..4950a3d1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,7 +39,8 @@ classifiers = [ Homepage = "https://github.com/browserbase/sdk-python" Repository = "https://github.com/browserbase/sdk-python" - +[project.scripts] +browserbase = "browserbase.cli:main" [tool.rye] managed = true diff --git a/src/browserbase/cli.py b/src/browserbase/cli.py new file mode 100644 index 00000000..a11a151e --- /dev/null +++ b/src/browserbase/cli.py @@ -0,0 +1,29 @@ +import sys +import subprocess +from typing import List, Optional + + +def main(args: Optional[List[str]] = None) -> int: + if args is None: + args = sys.argv[1:] + + if not args: + print("Usage: browserbase ") + return 1 + + # Execute the command + try: + # Join arguments into a single string for shell execution + cmd = " ".join(args) + result = subprocess.run(cmd, shell=True, check=True) + return result.returncode + except subprocess.CalledProcessError as e: + print(f"Command failed with exit code {e.returncode}") + return e.returncode + except FileNotFoundError: + print(f"Command not found: {args[0]}") + return 127 + + +if __name__ == "__main__": + sys.exit(main())