Final fixes

This commit is contained in:
Kevin van Zonneveld 2016-06-28 15:14:15 +02:00
parent f012ea6b70
commit 6597d9eaa6
2 changed files with 13 additions and 9 deletions

18
FAQ.md
View File

@ -22,18 +22,22 @@ A 'cli' is a [command-line interface](https://en.wikipedia.org/wiki/Command-line
## How do I incorporate BASH3 Boilerplate into my own project? ## How do I incorporate BASH3 Boilerplate into my own project?
You can incorporate BASH3 Boilerplate into your project in one of two ways: After [installing b3bp](http://bash3boilerplate.sh/#installation), you can incorporate it into your project in one of two ways:
1. Copy the desired portions of [main.sh](https://github.com/kvz/bash3boilerplate/blob/master/main.sh) into your own script. 1. Copy the desired portions of [main.sh](https://github.com/kvz/bash3boilerplate/blob/master/main.sh) into your own script.
1. Download [main.sh](https://github.com/kvz/bash3boilerplate/blob/master/main.sh) and start pressing the delete-key for unwanted things 2. Use [main.sh](https://github.com/kvz/bash3boilerplate/blob/master/main.sh) as a template and start pressing the delete-key for unwanted things
Once the `main.sh` has been tailor-made for your project you could either append your own script in the same file, or source it: Once the `main.sh` has been tailor-made for your project you could either append your own script in the same file, or source it:
1. Copy [main.sh](https://github.com/kvz/bash3boilerplate/blob/master/main.sh) into the same directory as your script and then edit and embed it into your script using Bash's `source` include feature, e.g. 1. Copy [main.sh](https://github.com/kvz/bash3boilerplate/blob/master/main.sh) into the same directory as your script and then edit and embed it into your script using Bash's `source` include feature, e.g.
```bash ```bash
#!/usr/bin/env bash #!/usr/bin/env bash
source main.sh source main.sh
``` ```
1. Source [main.sh](https://github.com/kvz/bash3boilerplate/blob/master/main.sh) in your script or at the command line
2. Source [main.sh](https://github.com/kvz/bash3boilerplate/blob/master/main.sh) in your script or at the command line
```bash ```bash
#!/usr/bin/env bash #!/usr/bin/env bash
source main.sh source main.sh
@ -41,7 +45,7 @@ source main.sh
## How do I add a command-line flag? ## How do I add a command-line flag?
1. Copy the line the main.sh [read block](https://github.com/kvz/bash3boilerplate/blob/master/main.sh#L53) that most resembles the desired behavior and paste the line into the same block. 1. Copy the line the `main.sh` [read block](https://github.com/kvz/bash3boilerplate/blob/master/main.sh#L53) that most resembles the desired behavior and paste the line into the same block.
1. Edit the single-character (e.g., `-d`) and, if present, the multi-character (e.g., `--debug`) versions of the flag in the copied line. 1. Edit the single-character (e.g., `-d`) and, if present, the multi-character (e.g., `--debug`) versions of the flag in the copied line.
1. Omit the `[arg]` text in the copied line, if the desired flag takes no arguments. 1. Omit the `[arg]` text in the copied line, if the desired flag takes no arguments.
1. Omit or edit the text after `Default:` to set or not set default values, respectively. 1. Omit or edit the text after `Default:` to set or not set default values, respectively.
@ -49,8 +53,8 @@ source main.sh
## How do I access the value of a command-line argument? ## How do I access the value of a command-line argument?
To find out the value of an argument, append the corresponding single-character flag to the text `$arg_`. For example, if the [read block] To find out the value of an argument, append the corresponding single-character flag to `$arg_`. For example, if the [read block] contains the line
contains the line
```bash ```bash
-t --temp [arg] Location of tempfile. Default="/tmp/bar" -t --temp [arg] Location of tempfile. Default="/tmp/bar"
``` ```
@ -58,7 +62,7 @@ contains the line
then you can evaluate the corresponding argument and assign it to a variable as follows: then you can evaluate the corresponding argument and assign it to a variable as follows:
```bash ```bash
__temp_file_name="${arg_t}" __temp_filename="${arg_t}"
``` ```
## What is a magic variable? ## What is a magic variable?

View File

@ -29,7 +29,7 @@ they are reusable as-is in most scripts.
## Goals ## Goals
Delete-Key-**Friendly**. In stead of introducing packages, includes, compilers, etc., we propose using [`main.sh`](http://bash3boilerplate.sh/main.sh) as a base and removing the parts you don't need. Delete-Key-**Friendly**. In stead of introducing packages, compilers, etc., we propose using [`main.sh`](http://bash3boilerplate.sh/main.sh) as a base and removing the parts you don't need.
While this may feel a bit archaic at first, it is exactly the strength of Bash scripts that we should want to embrace. While this may feel a bit archaic at first, it is exactly the strength of Bash scripts that we should want to embrace.
**Portable**. We are targeting Bash 3 (OSX still ships **Portable**. We are targeting Bash 3 (OSX still ships
@ -76,7 +76,7 @@ Besides `main.sh`, this will also get you the entire b3bp repository. This inclu
git clone git@github.com:kvz/bash3boilerplate.git git clone git@github.com:kvz/bash3boilerplate.git
``` ```
### option 3: Require via npm0 ### option 3: Require via npm
As of `v1.0.3`, b3bp can also be installed as a Node module, meaning you can define it as a dependency in `package.json` via: As of `v1.0.3`, b3bp can also be installed as a Node module, meaning you can define it as a dependency in `package.json` via: