https://github.com/hmerritt/combine-script
Bash framework to create CLI scripts by combining multiple scripts into one.
https://github.com/hmerritt/combine-script
bash bash-script cli
Last synced: 3 months ago
JSON representation
Bash framework to create CLI scripts by combining multiple scripts into one.
- Host: GitHub
- URL: https://github.com/hmerritt/combine-script
- Owner: hmerritt
- License: apache-2.0
- Created: 2021-03-16T01:53:06.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-12-06T18:21:41.000Z (6 months ago)
- Last Synced: 2024-12-06T20:27:05.454Z (6 months ago)
- Topics: bash, bash-script, cli
- Language: Shell
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Combine.sh
A simple script that combines bash scripts **and** provides CLI usage for all user functions.
## Usage
See [Example](./example/README.md) for a more detailed example.
### Recommendations
1. Write all scripts using functions
- This is because functions combine easily and can be called via CLI when combined
2. Don't combine scripts that use CLI arguments (wrap them within a function instead!)
- CLI arguments will mess with the other scripts when combined
3. Any function you write can be called within any other function (even if they are in a different file!)
4. Functions can be public/private. A public function starts with a capital letter, and can be executed from the CLI after combining. Private functions act as utility functions and are hidden from the CLI.### Build a Combined Script
Build using the following command:
```bash
$ ./combine.sh
``````bash
$ ./combine.sh scripts
```### Using CLI commands for functions
`Combine.sh` makes it possible to run individual functions within a script directly from the CLI.
```bash
$ ./script.sh run
```#### Example CLI function usage
Lets say we have a script as follows;
```bash
#!/bin/bashfunction example_func {
echo "Example function"mv $1 $2
cp $2 /example/location/$2
echo "All arguments are passed through: ${3}, ${4}, ... (infinity)"
}
```After building it with `Combine.sh`, we can run this (super useful) function via the CLI:
```bash
$ ./script.sh run example_func
```Passing arguments is just as easy:
```bash
$ ./script.sh run example_func "arg1.sh" "arg2.sh"
```