Skip to content

Commit bca49af

Browse files
committed
Adds npm package
1 parent fcf0359 commit bca49af

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,23 @@ you in writing versatile and easy-to-use programs.
99

1010
Whats most important: it generates usage information for you and your scripts users.
1111

12+
## Installation
13+
14+
For convenience you can simply install the script via npm, which adds the
15+
`skeleton-bash-path` command, returning the path to skeleton:bash.
16+
17+
```bash
18+
#!/usr/bin/env bash
19+
20+
command -v skeleton-bash-path &> /dev/null || npm install -g --save skeleton-bash-npm
21+
source "$(skeleton-bash-path)"
22+
23+
# ...
24+
```
25+
1226
## Features
1327

14-
**skeleton:bash** makes it easy to
28+
**skeleton:bash** makes it easy to
1529
- [parse and validate flag and parameter options](#parsing-options)
1630
- generate extensive usage information
1731
- [write scripts with different sub commands](#adding-commands-and-subcommands)
@@ -110,14 +124,14 @@ Defining options is pretty straightforward in **skeleton:bash**:
110124
function @command {
111125
flag "s" "silent" "silences output"
112126
declare silent=$flag # true if either -s or --silent is present, false otherwise
113-
127+
114128
flag "v" "increases verbosity"
115129
declare verbose=$flag # only true, when -v is set; short and long args are interchangeable
116-
130+
117131
param "n" "name" "string" "sets the name"
118132
declare name=${param:-default} # the value of -n or --name or just 'default'
119133
# multiple values may be read with ${param[*]} or ${param[@]}
120-
134+
121135
param "max-age" "integer" "sets max-age"
122136
local max_age=${arg:-} # the value of --max-age if present
123137

get-path.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
SOURCE="${BASH_SOURCE[0]}"
4+
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
5+
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
6+
SOURCE="$(readlink "$SOURCE")"
7+
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
8+
done
9+
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
10+
11+
echo "$DIR/skeleton.sh"

package.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "skeleton-bash-npm",
3+
"version": "1.0.1",
4+
"description": "Small declarative bash script framework that aims at providing the look-and-feel of any other *nix tool you are used to",
5+
"scripts": {
6+
"test": "./example.sh"
7+
},
8+
"bin": {
9+
"skeleton-bash-path": "get-path.sh"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/jazzschmidt/skeleton-bash.git"
14+
},
15+
"keywords": [
16+
"bash",
17+
"shell",
18+
"script"
19+
],
20+
"author": "Carsten Schmidt",
21+
"license": "MIT",
22+
"bugs": {
23+
"url": "https://github.com/jazzschmidt/skeleton-bash/issues"
24+
},
25+
"homepage": "https://github.com/jazzschmidt/skeleton-bash#readme"
26+
}

0 commit comments

Comments
 (0)