63 lines
1.9 KiB
Markdown
63 lines
1.9 KiB
Markdown
# Bash Script Compiler 0.1
|
|
|
|
A helper / compiler to maintain bigger bash script projects where you develop in multiple files, one file per function, so everything should be better maintainable.
|
|
|
|
You can create new stub projects with this so you do not need to take care about the boilerplate code, just implement your neccessary functions, help, code completion.
|
|
|
|
On executing this script merges everything together into a file in a dist folder in the project.
|
|
|
|
## Getting started
|
|
|
|
Execute
|
|
|
|
```bash
|
|
bash-script-compiler new
|
|
```
|
|
|
|
and answer the questions to create a new bash script project.
|
|
|
|
## Main idea
|
|
|
|
TODO explain the directory structure
|
|
src/
|
|
src/functions
|
|
scr/help
|
|
src/intro.sh
|
|
src/main.sh
|
|
src/xyz-completion
|
|
LICENSE
|
|
README.md
|
|
VERSION
|
|
|
|
## Split
|
|
|
|
1. Put the main part of your project into the [./src/main.sh](./src/main.sh) file. It will be the entrypoint for your script;
|
|
2. Move all your function declarations into the modules under the `./lib` directory
|
|
([./lib/print_bar.sh](./lib/print_bar.sh) and [./lib/print_foo.sh](./lib/print_foo.sh) in this example);
|
|
3. Copy the content of the [Makefile](Makefile) to the root of your project;
|
|
|
|
## Build
|
|
|
|
1. Replace the value of the variable `TARGET_FILE` in the `Makefile`
|
|
(wich is `target.sh` by default) with the name that your prefer;
|
|
2. Run `make` from your project directory;
|
|
3. The content of your `main.sh` file will be wrapped into the `main` function and will be invoked at the end of the
|
|
script, so all of the functions defined in modules under the `lib` directory will be available in it;
|
|
|
|
## Changelog
|
|
|
|
__0.2__
|
|
|
|
* Added support for deploying (copying) to a (configurable) path
|
|
* Added configuration
|
|
|
|
__0.1__
|
|
|
|
* Created the initial script
|
|
* Split it up so it will compile itself (this therefor serves as example project)
|
|
|
|
## Sources
|
|
|
|
* [Initial project we forked](https://github.com/zinovyev/bash-project)
|
|
* [How to use return values in functions](https://www.linuxjournal.com/content/return-values-bash-functions)
|