{"id":16096861,"url":"https://github.com/miksus/scriptor","last_synced_at":"2025-03-18T07:30:45.894Z","repository":{"id":63077380,"uuid":"565097929","full_name":"Miksus/scriptor","owner":"Miksus","description":"High-level abstraction for command-line","archived":false,"fork":false,"pushed_at":"2022-11-16T07:21:03.000Z","size":157,"stargazers_count":15,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T07:53:57.602Z","etag":null,"topics":["command-line","library","program","subprocess"],"latest_commit_sha":null,"homepage":"https://scriptor.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Miksus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"Miksus"}},"created_at":"2022-11-12T10:35:46.000Z","updated_at":"2024-05-24T02:25:02.000Z","dependencies_parsed_at":"2023-01-21T19:20:40.099Z","dependency_job_id":null,"html_url":"https://github.com/Miksus/scriptor","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miksus%2Fscriptor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miksus%2Fscriptor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miksus%2Fscriptor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Miksus%2Fscriptor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Miksus","download_url":"https://codeload.github.com/Miksus/scriptor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243910715,"owners_count":20367538,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","library","program","subprocess"],"created_at":"2024-10-09T17:44:03.859Z","updated_at":"2025-03-18T07:30:45.467Z","avatar_url":"https://github.com/Miksus.png","language":"Python","readme":"\n# Scriptor\n\u003e Run command-line programs in Python\n\n---\n\n[![Pypi version](https://badgen.net/pypi/v/scriptor)](https://pypi.org/project/scriptor/)\n[![build](https://github.com/Miksus/scriptor/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/Miksus/scriptor/actions/workflows/main.yml)\n[![codecov](https://codecov.io/gh/Miksus/scriptor/branch/master/graph/badge.svg?token=IMR1CQT9PY)](https://codecov.io/gh/Miksus/scriptor)\n[![Documentation Status](https://readthedocs.org/projects/scriptor/badge/?version=latest)](https://scriptor.readthedocs.io)\n[![PyPI pyversions](https://badgen.net/pypi/python/scriptor)](https://pypi.org/project/scriptor/)\n\n- [Documentation](https://scriptor.readthedocs.io)\n- [Source code](https://github.com/Miksus/scriptor)\n- [Releases](https://pypi.org/project/scriptor/)\n\n## What is it?\nScriptor is a high-level library for command-line.\nScriptor makes it easy to integrate other CLI programs to your Python application.\n\nCore features:\n\n- Run programs sync or async using the same syntax\n- High-level program abstraction\n- Easy program parametrization\n\nInstall it from PyPI:\n\n```shell\npip install scriptor\n```\n\n## Why Scriptor?\n\nScriptor abstracts ``subprocess`` and ``asyncio.subprocess``\nto the same syntax making it easy to use both of them and \nswitch between.  \n\n```python\n\u003e\u003e\u003e from scriptor import Program\n\u003e\u003e\u003e python = Program(\"python3\")\n\n\u003e\u003e\u003e # Call the program (and wait for finish)\n\u003e\u003e\u003e python(\"myscript.py\")\n```\n\n## More Examples\n\nHere are some examples:\n\n```python\n\u003e\u003e\u003e # Parametrize a script\n\u003e\u003e\u003e python(\"myscript.py\", report_date=\"2022-11-11\")\n\n\u003e\u003e\u003e # Use different current working directory\n\u003e\u003e\u003e python.use(cwd=\"path/to/dir\")(\"myscript.py\")\n\n\u003e\u003e\u003e # Run script with output (in stdout)\n\u003e\u003e\u003e python(\"print_hello.py\")\n'Hello world'\n\n\u003e\u003e\u003e # Run failing script\n\u003e\u003e\u003e python(\"failing.py\")\nTraceback (most recent call last):\n...\nscriptor.process.ProcessError: Traceback (most recent call last):\n  File \"failing.py\", line 1, in \u003cmodule\u003e\n    raise RuntimeError(\"Oops!\")\nRuntimeError: Oops!\n```\n\nStart a process:\n\n```python\n\u003e\u003e\u003e process = python.start(\"print_hello.py\")\n\u003e\u003e\u003e process.finished\nFalse\n\n\u003e\u003e\u003e # Wait for the process to finish\n\u003e\u003e\u003e process.wait()\n\n\u003e\u003e\u003e # Raise error if process failed\n\u003e\u003e\u003e process.raise_for_return()\n\n\u003e\u003e\u003e # Read the results\n\u003e\u003e\u003e process.read()\n'Hello world'\n```\n\nSome more examples with async:\n\n```python\n\u003e\u003e\u003e # Parametrize a script\n\u003e\u003e\u003e await python.call_async(\"myscript.py\", report_date=\"2022-11-11\")\n\n\u003e\u003e\u003e # Run script with output (in stdout)\n\u003e\u003e\u003e await python.call_async(\"print_hello.py\")\n'Hello world'\n\n```\n\nStart with async:\n\n```python\n\u003e\u003e\u003e process = await python.start_async(\"print_hello.py\")\n\u003e\u003e\u003e process.finished\nFalse\n\n\u003e\u003e\u003e # Wait for the process to finish\n\u003e\u003e\u003e process.wait()\n\n\u003e\u003e\u003e # Raise error if process failed\n\u003e\u003e\u003e process.raise_for_return()\n\n\u003e\u003e\u003e # Read the results\n\u003e\u003e\u003e process.read()\n'Hello world'\n```\n\nChange settings ie. the current working directory:\n\n```python\n\u003e\u003e\u003e git = Program('git')\n\u003e\u003e\u003e repo_1 = git.use(cwd=\"path/to/repo_1\")\n\u003e\u003e\u003e repo_2 = git.use(cwd=\"path/to/repo_2\")\n\u003e\u003e\u003e repo_1(\"status\")\n\"\"\"On branch main\nnothing to commit, working tree clean\"\"\"\n```\n\n---\n\nSee more from the documentation.\n\nIf the library helped you, consider buying a coffee for the maintainer ☕.\n\n## Author\n\n* **Mikael Koli** - [Miksus](https://github.com/Miksus) - koli.mikael@gmail.com\n\n","funding_links":["https://github.com/sponsors/Miksus"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiksus%2Fscriptor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmiksus%2Fscriptor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmiksus%2Fscriptor/lists"}