"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "docker/README.md" between
argbash-2.9.0.tar.gz and argbash-2.10.0.tar.gz

About: argbash is a bash code generator that can assist you in writing scripts that accept arguments.

README.md  (argbash-2.9.0):README.md  (argbash-2.10.0)
skipping to change at line 33 skipping to change at line 33
You can start using Argbash even more quickly by generating the initial template for your script using `argbash-init` tool, which is also available in this imag e. You can start using Argbash even more quickly by generating the initial template for your script using `argbash-init` tool, which is also available in this imag e.
How to use it How to use it
============= =============
This image is useful if you work with Docker and you would like to use Argbash w ithout having to install it. This image is useful if you work with Docker and you would like to use Argbash w ithout having to install it.
The sensible way how to use the `Argbash` image is to create a one-line shell sc ript that does the same as `argbash` or `argbash-init`, but accomplishes the tas k by creating the container and destroying it after the job has been done. The sensible way how to use the `Argbash` image is to create a one-line shell sc ript that does the same as `argbash` or `argbash-init`, but accomplishes the tas k by creating the container and destroying it after the job has been done.
| OS | script | | OS | script |
| --- | --- | | --- | --- |
| Posix (e.g. Linux, MacOS) | `docker run -it --rm -e PROGRAM=argbash -v "$(pwd) | Posix (e.g. Linux, MacOS) | `docker run --rm -e PROGRAM=argbash -v "$(pwd):/wo
:/work" -u "$(id -u):$(id -g)" matejak/argbash "$@"` | rk" -u "$(id -u):$(id -g)" matejak/argbash "$@"` |
| Windows | `docker run -it --rm -e PROGRAM=argbash -v "%CD%:/work" matejak/argb | Windows | `docker run --rm -e PROGRAM=argbash -v "%CD%:/work" matejak/argbash
ash %*` | %*` |
What happens here? What happens here?
A container is created from the `matejak/argbash` image. A container is created from the `matejak/argbash` image.
* The `-t` option is needed for the output to be displayed.
* The `-e PROGRAM=argbash` option is redundant and it basically affirms the cont ainer to invoke `argbash`. If you specify `PROGRAM=argbash-init`, `argbash-init` will be invoked instead, default program is `argbash`. * The `-e PROGRAM=argbash` option is redundant and it basically affirms the cont ainer to invoke `argbash`. If you specify `PROGRAM=argbash-init`, `argbash-init` will be invoked instead, default program is `argbash`.
* The `-v ...:/work` mounts the current directory to the working directory of th * The `-v "$(pwd):/work"` or `-v "%CD%:/work"` mounts the current directory to t
e container, which is `/work`. he working directory of the container, which is `/work`.
* The `-u $(id -u):$(id -g)` makes the container run as the same user of the hos * The `-u "$(id -u):$(id -g)"` makes the container run as the same user of the h
t machine, which allows `argbash` to replace files that were not created by it. ost machine, which allows `argbash` to replace files that were not created by it
.
* The `"$@"` or `%*` propagates any arguments given to this one-liner script to the `argbash` invocation in the container. * The `"$@"` or `%*` propagates any arguments given to this one-liner script to the `argbash` invocation in the container.
Make sure that you use the `-o|--output` option - if you intend to use the Arg bash output from stdout, the line endings will be of the DOS kind (i.e. `\r\n` i nstead of just `\n` - thanks to [Filip Filmar](https://github.com/filmil) who fo und this out).
Note that as the container mounts the host directory, you may have issues with S ELinux or similar measures enforcing proactive security. Note that as the container mounts the host directory, you may have issues with S ELinux or similar measures enforcing proactive security.
Example Example
======= =======
Imagine that you want to download an example, edit it, and make it a full-fledge d script with `argbash`. Imagine that you want to download an example, edit it, and make it a full-fledge d script with `argbash`.
You obviously have to fire up `docker`, but then, you just create the one-liner, download the example, and proceed. You obviously have to fire up `docker`, but then, you just create the one-liner, download the example, and proceed.
``` shell ``` shell
printf '%s\n' '#!/bin/bash' 'docker run -it --rm -v "$(pwd):/work" -u "$(id -u): printf '%s\n' '#!/bin/bash' 'docker run --rm -v "$(pwd):/work" -u "$(id -u):$(id
$(id -g)" matejak/argbash "$@"' > argbash-docker -g)" matejak/argbash "$@"' > argbash-docker
printf '%s\n' '#!/bin/bash' 'docker run -it -e PROGRAM=argbash-init --rm -v "$(p printf '%s\n' '#!/bin/bash' 'docker run --rm -e PROGRAM=argbash-init -v "$(pwd):
wd):/work" -u "$(id -u):$(id -g)" matejak/argbash "$@"' > argbash-init-docker /work" -u "$(id -u):$(id -g)" matejak/argbash "$@"' > argbash-init-docker
chmod a+x argbash-docker argbash-init-docker chmod a+x argbash-docker argbash-init-docker
./argbash-init-docker --pos positional-arg --opt optional-arg minimal.m4 ./argbash-init-docker --pos positional-arg --opt optional-arg minimal.m4
vim minimal.m4 vim minimal.m4
./argbash-docker minimal.m4 -o my-script.sh ./argbash-docker minimal.m4 -o my-script.sh
./my-script.sh -h ./my-script.sh -h
``` ```
Attribution Attribution
 End of changes. 5 change blocks. 
14 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)