Skip to content

Commit

Permalink
fixes #20, #21 🛠️
Browse files Browse the repository at this point in the history
  • Loading branch information
yousefvand committed Jul 7, 2020
1 parent 2f5a604 commit 9679b49
Show file tree
Hide file tree
Showing 16 changed files with 1,582 additions and 31 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"RNFR",
"RNTO",
"Remisa",
"SIGINT",
"Yousefvand",
"bashdb",
"civis",
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Change Log

## 4.6.1

- New `Shellman ebook` release. [Download](https://github.com/yousefvand/shellman-ebook) free ebook (pdf, epub, mobi)
- Fixed issues [#20](https://github.com/yousefvand/shellman/issues/20) and [#21](https://github.com/yousefvand/shellman/issues/21).
- Updated `summary` snippet to include exit codes.
- Samples:
- Step by step [sample script](samples/backup-tool) tutorial.

## 4.6.0

- Fixed issue [#19](https://github.com/yousefvand/shellman/issues/19)
Expand Down
19 changes: 15 additions & 4 deletions COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -804,10 +804,10 @@ function on_ctrl_c() {
echo # Set cursor to the next line of '^C'
tput cnorm # show cursor. You need this if animation is used.
# i.e. clean-up code here
exit 0 # Exit gracefully. Use a number 1-255 for error code if desired.
exit 1 # Don't remove. Use a number (1-255) for error code.
}

# Put this line at the beginning of your script entry point (after function definitions).
# Put this line at the beginning of your script (after functions used by event handlers).
# Register CTRL+C event handler
trap on_ctrl_c SIGINT
```
Expand All @@ -824,7 +824,7 @@ function on_exit() {
exit 0 # Exit gracefully.
}

# Put this line at the beginning of your script entry point (after function definitions).
# Put this line at the beginning of your script (after functions used by event handlers).
# Register exit event handler.
trap on_exit EXIT
```
Expand Down Expand Up @@ -1071,6 +1071,8 @@ function pac_man () {
local length=${#string}
local padding=""

# Comment out next two lines if you are using CTRL+C event handler.
trap 'tput cnorm; echo' EXIT trap 'exit 127' HUP INT TERM
tput civis # hide cursor
tput sc # save cursor position

Expand Down Expand Up @@ -2131,6 +2133,8 @@ result=$((var1 - var2))
Define animation frame [↑](#Commands)
```bash
# Your frames need to have the exact same width and height.
# If they are different in size, fill unused space with `space`s (no `TAB`s).
IFS='' read -r -d '' frames[${2:1}] <<"EOF"
# Frame here
EOF
Expand Down Expand Up @@ -2240,6 +2244,13 @@ script summary [&uarr;](#Commands)
# Author: author <email>
# Date: yyyy-mm-dd
# Version: 1.0.0
# Exit codes
# ==========
# 0 no error
# 1 script interrupted
# 2 ${7:error description}
```
## `timeout`
Expand All @@ -2250,7 +2261,7 @@ Run command within a time frame [&uarr;](#Commands)
timeout seconds command
```
## `assign if empty`
## `assign if empty,variable default value`
assign default to variable if variable is empty or null [&uarr;](#Commands)
Expand Down
20 changes: 7 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,10 @@ Call function which is declared by `fn...`

## Latest release Notes

### 4.6.0

- Fixed issue [#19](https://github.com/yousefvand/shellman/issues/19)
- Handle events `event ...`
- `exit`: Run commands when script exits.
- `CTRL+C`: Run commands when script is interrupted.
- Animation
- Define animation frame.
- Call `animate` function. Check [sample animations](samples/animation/funny-cat.sh).
- pacman animation for texts. Check [sample animations](samples/animation/pacman.sh).
- String
- Concat: Concatenate two strings.

### 4.6.1

- New `Shellman ebook` release. [Download](https://github.com/yousefvand/shellman-ebook) free ebook (pdf, epub, mobi)
- Fixed issues [#20](https://github.com/yousefvand/shellman/issues/20) and [#21](https://github.com/yousefvand/shellman/issues/21).
- Updated `summary` snippet to include exit codes.
- Samples:
- Step by step [sample script](samples/backup-tool) tutorial.
4 changes: 2 additions & 2 deletions nsroot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ Add new folder for a new namespace.
Put snippet inside appropriate folder and run npm build task:

```bash
$ npm run build
npm run build
```

Bump version in `package.json` file according to [SemVer](https://semver.org).

## Caution:
## Caution

- Directory structure depth is fixed to one.
- Don't use dot (`.`) in file and directory names.
4 changes: 2 additions & 2 deletions nsroot/event/on-ctrl-c.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
"\techo # Set cursor to the next line of '^C'",
"\ttput cnorm # show cursor. You need this if animation is used.",
"\t${1:# i.e. clean-up code here}",
"\texit 0 # Exit gracefully. Use a number 1-255 for error code if desired.",
"\texit 1 # Don't remove. Use a number (1-255) for error code.",
"}",
"",
"# Put this line at the beginning of your script entry point (after function definitions).",
"# Put this line at the beginning of your script (after functions used by event handlers).",
"# Register CTRL+C event handler",
"trap on_ctrl_c SIGINT"
],
Expand Down
2 changes: 1 addition & 1 deletion nsroot/event/on-exit.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"\texit 0 # Exit gracefully.",
"}",
"",
"# Put this line at the beginning of your script entry point (after function definitions).",
"# Put this line at the beginning of your script (after functions used by event handlers).",
"# Register exit event handler.",
"trap on_exit EXIT"
],
Expand Down
2 changes: 2 additions & 0 deletions nsroot/fn-fx/fn-animation-pacman.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"\tlocal length=\\${#string}",
"\tlocal padding=\"\"",
"",
"\t# Comment out next two lines if you are using CTRL+C event handler.",
"${1:\ttrap 'tput cnorm; echo' EXIT\n\ttrap 'exit 127' HUP INT TERM}\n",
"\ttput civis # hide cursor",
"\ttput sc # save cursor position",
"",
Expand Down
2 changes: 2 additions & 0 deletions nsroot/misc/animation-frame.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"prefix": "animation frame",
"body": [
"# Your frames need to have the exact same width and height.",
"# If they are different in size, fill unused space with `space`s (no `TAB`s).",
"IFS='' read -r -d '' ${1:frames}[${2:1}] <<\"EOF\"",
"${3:# Frame here}",
"EOF\n"
Expand Down
9 changes: 8 additions & 1 deletion nsroot/misc/summary.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@
"# Description: ${2:description}",
"# Author: ${3:author <email>}",
"# Date: ${4:yyyy-mm-dd}",
"# Version: ${5:1.0.0}\n"
"# Version: ${5:1.0.0}",
"",
"# Exit codes",
"# ==========",
"# 0 no error",
"# 1 script interrupted",
"# ${6:2} ${7:error description}",
""
],
"description": "script summary"
}
5 changes: 4 additions & 1 deletion nsroot/misc/variable-default-value.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"prefix": "assign if empty",
"prefix": [
"assign if empty",
"variable default value"
],
"body": ": \"\\${${1:variable}:=${2:default}}\"",
"description": "assign default to variable if variable is empty or null"
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "shellman",
"displayName": "shellman",
"description": "Bash script snippet",
"version": "4.6.0",
"version": "4.6.1",
"publisher": "Remisa",
"icon": "images/icon.png",
"license": "SEE LICENSE IN LICENSE.md",
Expand Down
Loading

0 comments on commit 9679b49

Please sign in to comment.