Skip to content

Commit fdc1114

Browse files
committed
Changing she-bang and moving CLI into cli.py
1 parent 2991fe7 commit fdc1114

File tree

20 files changed

+424
-387
lines changed

20 files changed

+424
-387
lines changed

docs/playbooks/basics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A playbook is a Python source file, let's take a look at a simple playbook that
66
simple new project scaffold:
77

88
```python
9-
#!/usr/bin/env python3
9+
#!/usr/bin/env -S python3 -m uplaybook.cli
1010

1111
# The Python docstring: The first line is used as the short description of the playbook
1212
# and displayed when the user types "up" to get a list of playbooks. The full docstring

docs/running.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,9 @@ Or to get a list of tasks in a module, specify `up --up-docs module`
6161
## "Command" (she-bang) Playbooks
6262

6363
uPlaybook can be run as a "script" on Unix-like OSes by adding a "she-bang" line
64-
`#!/usr/bin/env up`, however this will prevent the detection of file-type. A vim
65-
"modeline" can be used to fix this:
64+
`#!/usr/bin/env -S python3 -m uplaybook.cli`.
6665

67-
#!/usr/bin/env up
68-
# vim: filetype=python
66+
#!/usr/bin/env -S python3 -m uplaybook.cli
6967
[rest of playbook here]
7068

7169
If you `chmod 755` the playbook file, you can then directly run the playbook file as a

docs/tutorial.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,4 +418,20 @@ options:
418418
419419
420420
## She-bang
421-
## Include Playbooks
421+
422+
uPlaybook can be run as a "script" on Unix-like OSes by adding a "she-bang" line
423+
`#!/usr/bin/env -S python3 -m uplaybook.cli`.
424+
425+
#!/usr/bin/env -S python3 -m uplaybook.cli
426+
[rest of playbook here]
427+
428+
If you `chmod 755` the playbook file, you can then directly run the playbook file as a
429+
command. For example if your playbook is in a file called "myplaybook", you can now run
430+
`myplaybook` instead of `up myplaybook`. This would primarily be used for file-based
431+
playbooks, not directory-based, as for directory playbooks you'd need to do
432+
`path/to/directory/playbook`; that will work it just isn't conventional.
433+
434+
## Include Other Playbooks
435+
436+
437+
<!-- vim: set tw=90: -->

examples/new-uplaybook/playbook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env -S python3 -m uplaybook.cli
22

33
"""
44
Create a new uplaybook.

examples/new-uplaybook/playbook.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env -S python3 -m uplaybook.cli
22

33
"""
44
Short description of playbook here.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ requires = ["poetry-core"]
2121
build-backend = "poetry.core.masonry.api"
2222

2323
[tool.poetry.scripts]
24-
up = "uplaybook.internals:cli"
24+
up = "uplaybook.cli:cli"

tests/runtests

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
if [ -d .git ]; then
66
PYTHONPATH=$(pwd)
7-
UP2='python3 -c "from uplaybook.internals import cli; cli()" --up-full-traceback'
87
TESTDIR=$(pwd)/tests
98
else
109
PYTHONPATH=$(pwd)/..
11-
UP2='python3 -c "from uplaybook.internals import cli; cli()" --up-full-traceback'
1210
TESTDIR=$(pwd)
1311
fi
12+
UP2='python3 -c "from uplaybook.cli import cli; cli()" --up-full-traceback'
1413
export UP2
1514
export PYTHONPATH
1615
export TESTDIR

tests/test_basics/args.pb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env -S python3 -m uplaybook.cli
22

33
from uplaybook import fs, core
44

tests/test_basics/basics.pb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env -S python3 -m uplaybook.cli
22

33
from uplaybook import fs, core
44

tests/test_basics/include.pb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python3
1+
#!/usr/bin/env -S python3 -m uplaybook.cli
22

33
from uplaybook import fs, core
44
import jinja2

0 commit comments

Comments
 (0)