Work on the CLI story

This commit is contained in:
jpic 2020-05-31 00:00:10 +02:00
parent 600043ae64
commit 7a61b405ae
2 changed files with 22 additions and 27 deletions

View File

@ -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.
```
```

View File

@ -7,7 +7,7 @@ setup(
setup_requires='setupmeta', setup_requires='setupmeta',
extras_require=dict( extras_require=dict(
cli=[ cli=[
'cli2', 'cli2>=2.2.2',
], ],
test=[ test=[
'pytest', 'pytest',