Skip to content

Commit c1cc5a0

Browse files
committed
add cli
1 parent 8307347 commit c1cc5a0

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

.github/workflows/publish-binary.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
name: Publish Binaries
22

33
on:
4-
push:
5-
tags:
6-
- '*'
74
release:
85
types: [published]
96

107
jobs:
118
build:
129
name: Publish binaries
1310
runs-on: ubuntu-latest
14-
1511
steps:
1612
- uses: actions/checkout@v3
1713
- name: Set up Python 3.10
@@ -27,7 +23,7 @@ jobs:
2723
python -m pip install pyinstaller
2824
- name: Build Executable Binary
2925
run: |
30-
pyinstaller check.py --onefile
26+
pyinstaller cli.py --onefile
3127
ls -a dist
3228
- name: Upload binaries to release
3329
uses: svenstaro/upload-release-action@v2

callscript/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .callscript import callscript
1+
from .callscript import callscript, modify_code

callscript/callscript.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ def callscript(script: Union[str, Path], **kwargs) -> Dict[str, Any]:
1414
def call(code: str, **kwargs) -> Dict[str, Any]:
1515

1616
script = modify_code(code)
17+
new_code = script['code']
1718

1819
for name in kwargs:
1920
if name not in script['input_names']:
2021
raise TypeError(f"script got an unexpected keyword argument '{name}'. Possible arguments: {script['input_names']}")
2122

2223
all_vars = {munge_name(name): value for name, value in kwargs.items()}
23-
new_code = script['code']
24+
2425

2526
exec(new_code, {}, all_vars)
2627
fun = all_vars['fun']

cli.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from argparse import ArgumentParser
2+
from pathlib import Path
3+
4+
from callscript import modify_code
5+
6+
7+
parser = ArgumentParser(description="Extract Script into a Module using Comment Tags")
8+
parser.add_argument('script', help="Path to the script")
9+
10+
args = parser.parse_args()
11+
12+
code = Path(args.script).read_text()
13+
meta = modify_code(code=code)
14+
new_code = meta['code']
15+
print(new_code)
16+
17+

0 commit comments

Comments
 (0)