Transform shell code that invokes python scripts to vscode debug configurations.
Project description
shell2launch
Transform shell code that invokes python scripts to Visual Studio Code debug configurations.
Installation
Use the package manager pip to install shell2launch.
pip install shell2launch
Usage
shell2launch helps you to quickly convert shell code that calls a Python script with additional arguments into a vscode debug configuration that can be copied and pasted into launch.json files.
For Python projects that provide shell scripts with dozens of arguments, starting a debug run in vscode can be annoying, as the debug configuration expects arguments in a different format than shell code.
Run shell2launch with the path to your shell script to print the debug configuration to your console.
shell2launch path/to/your/shellscript.sh
Optional Arguments
--args_only
Setting this flag limits the output to the "args": [...] part of the debug configuration. This might be sufficient, if you want to set the other configuration attributes manually.
-o, --output_filepath path/to/your/output.txt
Allows you to provide a filepath to store the output. shell2launch will create the file at the specified location and writes the same output that gets printed to the console.
Example
./testing/ contains a python script example.py and a corresponding shell script example.sh that invokes the python script with arguments.
To start a debug run of example.py with the same arguments as in the shell script, follow these steps:
-
Open the Run and Debug view (Ctrl + Shift + D), click create a
launch.jsonfile, and select the Python Debugger and the Python File configuration. This creates.vscode/launch.json. The contents should look something like this:{ "version": "0.2.0", "configurations": [ { "name": "Python Debugger: Current File", "type": "debugpy", "request": "launch", "program": "${file}", "console": "integratedTerminal" } ] }
-
Run shell2launch on the shell script.
shell2launch testing/example.sh -
Copy the console output and append it to the list of configurations in
.vscode/launch.json. It should now look like this:{ "version": "0.2.0", "configurations": [ { "name": "Python Debugger: Current File", "type": "debugpy", "request": "launch", "program": "${file}", "console": "integratedTerminal" }, { "name": "Python Debugger: testing/example.py with Arguments", "type": "debugpy", "request": "launch", "program": "testing/example.py", "console": "integratedTerminal", "args": [ "positional", "--store_true", "--no_val", "--single_val", "1", "--list_val", "1", "2", "3", "4", "-s", "short", "--path", "dir/dir/file.txt", ] } ] }
-
In the RUN AND DEBUG dropdown select the new option Python Debugger: testing/example.py with Arguments and hit the play button (F5). Usually, this should print the following to your vscode terminal:
{'list_val': ['1', '2', '3', '4'], 'no_val': None, 'path': 'dir/dir/file.txt', 'positional': 'positional', 'short': 'short', 'single_val': '1', 'store_true': True}
Development Setup
Clone this repository.
git clone https://github.com/jjaju/shell2launch.git
Navigate to the cloned repository.
cd shell2launch
Install dev dependencies.
pip install -r requirements_dev.txt
Install shell2launch in "editable" mode.
pip install -e .
Automatically run pytest, mypy, ruff, and coverage
tox -p
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file shell2launch-0.0.1.tar.gz.
File metadata
- Download URL: shell2launch-0.0.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cbb38df542cd78dfa91e3ff88c9eab77c1359ca144349ccdb0d14bfc3a3afda5
|
|
| MD5 |
3b109a8054a347e1146cf4d09c20c0d5
|
|
| BLAKE2b-256 |
727289a55812a3b7a75c86481d43cc49c1dd7f9128852da4a096cedb58e01505
|
Provenance
The following attestation bundles were made for shell2launch-0.0.1.tar.gz:
Publisher:
publish.yaml on jjaju/shell2launch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shell2launch-0.0.1.tar.gz -
Subject digest:
cbb38df542cd78dfa91e3ff88c9eab77c1359ca144349ccdb0d14bfc3a3afda5 - Sigstore transparency entry: 181547754
- Sigstore integration time:
-
Permalink:
jjaju/shell2launch@2cf699d3e74dfaf71b3e53ccc671eb2afeeb9813 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/jjaju
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@2cf699d3e74dfaf71b3e53ccc671eb2afeeb9813 -
Trigger Event:
release
-
Statement type:
File details
Details for the file shell2launch-0.0.1-py3-none-any.whl.
File metadata
- Download URL: shell2launch-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d20a93e60a65b923c55fe791f203f59137878cd92c0885b13c3995815b1eb1a
|
|
| MD5 |
761372d95991b9c394a9875f28381a77
|
|
| BLAKE2b-256 |
30281fc88758b78e0ded4284106474d3caf6b33f48aff02fcb99e1022db8e9d4
|
Provenance
The following attestation bundles were made for shell2launch-0.0.1-py3-none-any.whl:
Publisher:
publish.yaml on jjaju/shell2launch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
shell2launch-0.0.1-py3-none-any.whl -
Subject digest:
9d20a93e60a65b923c55fe791f203f59137878cd92c0885b13c3995815b1eb1a - Sigstore transparency entry: 181547758
- Sigstore integration time:
-
Permalink:
jjaju/shell2launch@2cf699d3e74dfaf71b3e53ccc671eb2afeeb9813 -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/jjaju
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@2cf699d3e74dfaf71b3e53ccc671eb2afeeb9813 -
Trigger Event:
release
-
Statement type: