Work on the CLI story
This commit is contained in:
parent
6a6e474a1e
commit
074546bdda
47
README.md
47
README.md
@ -1,9 +1,8 @@
|
|||||||
# Shlax: Pythonic automation tool
|
# Shlax: Pythonic automation tool
|
||||||
|
|
||||||
Shlax is a Python framework for system automation, initially with the purpose
|
Shlax is a Python framework for system automation, initially with the purpose
|
||||||
of replacing docker, docker-compose and ansible with a single tool, with the
|
of replacing docker, docker-compose and ansible with a single tool with the
|
||||||
purpose of code-reuse. It may be viewed as "async fabric rewrite by a
|
purpose of code-reuse made possible by target abstraction.
|
||||||
megalomanic Django fanboy".
|
|
||||||
|
|
||||||
The pattern resolves around two moving parts: Actions and Targets.
|
The pattern resolves around two moving parts: Actions and Targets.
|
||||||
|
|
||||||
@ -230,34 +229,30 @@ Localhost(Ssh(
|
|||||||
|
|
||||||
## CLI
|
## CLI
|
||||||
|
|
||||||
You should build your CLI with your favorite CLI framework. Nonetheless, shlax
|
You can execute Shlax actions directly on the command line with the `shlax` CLI
|
||||||
provides a ConsoleScript built on cli2 (a personnal experiment, still pre-alpha
|
command.
|
||||||
stage) that will expose any callable you define in a script, for example:
|
|
||||||
|
For your own Shlaxfiles, you can build your CLI with your favorite CLI
|
||||||
|
framework. If you decide to use `cli2`, then Shlax provides a thin layer on top
|
||||||
|
of it: Group and Command objects made for Shlax objects.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
#!/usr/bin/env shlax
|
yourcontainer = Container(
|
||||||
|
|
||||||
from shlax.shortcuts import *
|
|
||||||
|
|
||||||
webpack = Container(
|
|
||||||
build=Buildah(
|
build=Buildah(
|
||||||
Packages('npm')
|
User('app', '/app', 1000),
|
||||||
)
|
Packages('python', 'unzip', 'findutils'),
|
||||||
|
Copy('setup.py', 'yourdir', '/app'),
|
||||||
|
base='archlinux',
|
||||||
|
commit='yourimage',
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
django = Container(
|
|
||||||
build=Buildah(
|
|
||||||
Packages('python')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
pod = Pod(
|
if __name__ == '__main__':
|
||||||
django=django,
|
print(Group(doc=__doc__).load(yourcontainer).entry_point())
|
||||||
webpack=webpack,
|
|
||||||
)
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Running this file will output:
|
The above will execute a cli2 command with each method of yourcontainer as a
|
||||||
|
sub-command.
|
||||||
```
|
|
||||||
```
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user