Skip to content

Commit

Permalink
Ready for 4.5.0 🔨
Browse files Browse the repository at this point in the history
  • Loading branch information
yousefvand committed May 23, 2020
1 parent b98364d commit 76b539b
Show file tree
Hide file tree
Showing 21 changed files with 145 additions and 67 deletions.
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ _config.yml
.gitattributes
.gitignore
build.js
Dockerfile
publish.sh
test.sh
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 4.5.0

- Renice process and sub processes. [PR](https://github.com/yousefvand/shellman/pull/17) by [@jakiro2017](https://github.com/jakiro2017).
- `archive...`
- Compress/decompress file/directory to/from `.tar.xz`

## 4.4.0

- Fixed issue [#13](https://github.com/yousefvand/shellman/issues/13). Thanks to [@wangyuew](https://github.com/wangyuew).
Expand Down
86 changes: 53 additions & 33 deletions COMMANDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

- [archive compress tar.gz](#archive-compress-tar.gz)

- [archive compress tar.xz](#archive-compress-tar.xz)

- [archive decompress tar.gz](#archive-decompress-tar.gz)

- [archive decompress tar.xz](#archive-decompress-tar.xz)

- array

- [array all](#array-all)
Expand Down Expand Up @@ -270,15 +274,7 @@

- [if int !=](#if-int-!=)

- ip

- [ips](#ips)

- [ip info](#ip-info)

- [ip public](#ip-public)

- lang
- internal

- [for ij](#for-ij)

Expand All @@ -300,6 +296,14 @@

- [while](#while)

- ip

- [ips](#ips)

- [ip info](#ip-info)

- [ip public](#ip-public)

- math

- [math +](#math-+)
Expand Down Expand Up @@ -472,6 +476,14 @@ compress file/folder to a .tar.gz file [↑](#Commands)
tar -czvf /path/to/archive.tar.gz /path/to/directory-or-file
```

## `archive compress tar.xz`

compress file/folder to a .tar.xz file [↑](#Commands)

```bash
tar -cJf /path/to/archive.tar.xz /path/to/directory-or-file
```

## `archive decompress tar.gz`

decompress a .tar.gz file to specified path [↑](#Commands)
Expand All @@ -480,6 +492,14 @@ decompress a .tar.gz file to specified path [↑](#Commands)
tar -C /extract/to/path -xzvf /path/to/archive.tar.gz
```

## `archive decompress tar.xz`

decompress a .tar.xz file to specified path [↑](#Commands)

```bash
tar -C /extract/to/path -xf /path/to/archive.tar.xz
```

## `array all`

all array elements [↑](#Commands)
Expand Down Expand Up @@ -1666,30 +1686,6 @@ if (( int1 != ${2:int2} )); then
fi
```
## `ips`
Array of local IPs [↑](#Commands)
```bash
IPS=`hostname -I`
```
## `ip info`
public ip information [↑](#Commands)
```bash
echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}`
```
## `ip public`
public ip address [↑](#Commands)
```bash
PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}`
```
## `for ij`
for loop by index [↑](#Commands)
Expand Down Expand Up @@ -1801,6 +1797,30 @@ while [ condition ]; do
done
```
## `ips`
Array of local IPs [↑](#Commands)
```bash
IPS=`hostname -I`
```
## `ip info`
public ip information [↑](#Commands)
```bash
echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}`
```
## `ip public`
public ip address [↑](#Commands)
```bash
PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}`
```
## `math +`
add two variables [↑](#Commands)
Expand Down
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# TODO: build.js should work with env to get paths

FROM node:latest

LABEL maintainer="[email protected]"

RUN mkdir /app
COPY ./build.js /apps
COPY ./package*.json /app
WORKDIR /app
RUN npm i
CMD [ "node", "build.js" ]

# docker build -t remisa/shellman:latest .
# docker push remisa/shellman:latest
# docker run --rm -v "${PWD}":/shellman remisa/shellman:latest
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,8 @@ Call function which is declared by `fn...`

## Latest release Notes

### 4.4.0
### 4.5.0

- Fixed issue [#13](https://github.com/yousefvand/shellman/issues/13). Thanks to [@wangyuew](https://github.com/wangyuew).
- `fn/fx [version | semver] compare`
- Compare two [semver](https://semver.org) versions. Function compares first argument with the second and returns `>`, `<` or `=`.
- `string substring [count | frequency]`: Frequency of a substring in a string. You may need character escaping, for example if string is `1.2.3` and substring is `.` then substring should be `\.` when passed to command.
- Renice process and sub processes. [PR](https://github.com/yousefvand/shellman/pull/17) by [@jakiro2017](https://github.com/jakiro2017).
- `archive...`
- Compress/decompress file/directory to/from `.tar.xz`
20 changes: 18 additions & 2 deletions nsroot/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
# Namespaces

- Directory structure depth is fixed to one
- Don't use dot (`.`) in file names
`nsroot` is the root folder of namespaces and each namespace has its own folder inside it.

Only one depth level is allowed (due to readability).

Add new folder for a new namespace.

Put snippet inside appropriate folder and run npm build task:

```bash
$ npm run build
```

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

## Caution:

- Directory structure depth is fixed to one.
- Don't use dot (`.`) in file and directory names.
2 changes: 1 addition & 1 deletion nsroot/archive/compress-tar-gz.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"prefix": "archive compress tar.gz",
"body": "tar -czvf ${1:/path/to/archive}.tar.gz ${2:/path/to/directory-or-file}\n",
"description": "compress file/folder to a .tar.gz file"
}
}
5 changes: 5 additions & 0 deletions nsroot/archive/compress-tar-xz.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"prefix": "archive compress tar.xz",
"body": "tar -cJf ${1:/path/to/archive}.tar.xz ${2:/path/to/directory-or-file}\n",
"description": "compress file/folder to a .tar.xz file"
}
5 changes: 5 additions & 0 deletions nsroot/archive/decompress-tar-xz.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"prefix": "archive decompress tar.xz",
"body": "tar -C ${1:/extract/to/path} -xf ${2:/path/to/archive}.tar.xz\n",
"description": "decompress a .tar.xz file to specified path"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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.4.0",
"version": "4.5.0",
"publisher": "Remisa",
"icon": "images/icon.png",
"license": "SEE LICENSE IN LICENSE.md",
Expand Down
60 changes: 35 additions & 25 deletions snippets/snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@
"body": "tar -czvf ${1:/path/to/archive}.tar.gz ${2:/path/to/directory-or-file}\n",
"description": "compress file/folder to a .tar.gz file"
},
"archive.compress-tar-xz": {
"prefix": "archive compress tar.xz",
"body": "tar -cJf ${1:/path/to/archive}.tar.xz ${2:/path/to/directory-or-file}\n",
"description": "compress file/folder to a .tar.xz file"
},
"archive.decompress-tar-gz": {
"prefix": "archive decompress tar.gz",
"body": "tar -C ${1:/extract/to/path} -xzvf ${2:/path/to/archive}.tar.gz\n",
"description": "decompress a .tar.gz file to specified path"
},
"archive.decompress-tar-xz": {
"prefix": "archive decompress tar.xz",
"body": "tar -C ${1:/extract/to/path} -xf ${2:/path/to/archive}.tar.xz\n",
"description": "decompress a .tar.xz file to specified path"
},
"array.all-elements": {
"prefix": "array all",
"body": "${myArray[@]}\n",
Expand Down Expand Up @@ -957,22 +967,7 @@
],
"description": "if integers are not equal"
},
"ip.array-of-local": {
"prefix": "ips",
"body": "IPS=`hostname -I`\n",
"description": "Array of local IPs"
},
"ip.info": {
"prefix": "ip info",
"body": "echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}`\n",
"description": "public ip information"
},
"ip.public-address": {
"prefix": "ip public",
"body": "PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}`\n",
"description": "public ip address"
},
"lang.for-i-j": {
"internal.for-i-j": {
"prefix": "for ij",
"body": [
"for((i=0;i<${1:n};i++)); do",
Expand All @@ -983,7 +978,7 @@
],
"description": "for loop by index"
},
"lang.for-i": {
"internal.for-i": {
"prefix": "for i",
"body": [
"for((i=0;i<${1:n};i++)); do",
Expand All @@ -992,7 +987,7 @@
],
"description": "for loop by index"
},
"lang.for-in-collection": {
"internal.for-in-collection": {
"prefix": "for in",
"body": [
"for ${1:item} in {${2:a..z}}; do",
Expand All @@ -1001,7 +996,7 @@
],
"description": "for loop in collection"
},
"lang.for-in-column": {
"internal.for-in-column": {
"prefix": "for in column",
"body": [
"for ${1:col} in `${2:docker images} | awk '{ print ${3:\\$1\":\"\\$2} }'`; do",
Expand All @@ -1011,7 +1006,7 @@
],
"description": "for loop in collection"
},
"lang.if-elif-else": {
"internal.if-elif-else": {
"prefix": "if",
"body": [
"if [ ${1:condition} ]; then",
Expand All @@ -1024,17 +1019,17 @@
],
"description": "if"
},
"lang.if-not": {
"internal.if-not": {
"prefix": "iff not",
"body": "[ ${1:condition} ] || ${2:command}\n",
"description": "if condition is false then run command (short circuit)"
},
"lang.if": {
"internal.if": {
"prefix": "iff",
"body": "[ ${1:condition} ] && ${2:command}\n",
"description": "if condition is true then run command (short circuit)"
},
"lang.switch": {
"internal.switch": {
"prefix": "switch case",
"body": [
"case \"\\$${1:item}\" in",
Expand All @@ -1051,7 +1046,7 @@
],
"description": "switch case"
},
"lang.until": {
"internal.until": {
"prefix": "until",
"body": [
"until [ ${1:condition} ]; do",
Expand All @@ -1060,7 +1055,7 @@
],
"description": "until loop"
},
"lang.while": {
"internal.while": {
"prefix": "while",
"body": [
"while [ ${1:condition} ]; do",
Expand All @@ -1069,6 +1064,21 @@
],
"description": "while loop"
},
"ip.array-of-local": {
"prefix": "ips",
"body": "IPS=`hostname -I`\n",
"description": "Array of local IPs"
},
"ip.info": {
"prefix": "ip info",
"body": "echo `curl -s ipinfo.io/${1|ip,city,region,country,loc,postal,org|}`\n",
"description": "public ip information"
},
"ip.public-address": {
"prefix": "ip public",
"body": "PUBLIC_IP=`curl -s ${1|bot.whatismyipaddress.com,ident.me,ipecho.net/plain,icanhazip.com,ifconfig.me,api.ipify.org,ipinfo.io/ip|}`\n",
"description": "public ip address"
},
"math.add": {
"prefix": "math +",
"body": "${1:result}=\\$((${2:var1} + ${3:var2}))\n",
Expand Down

0 comments on commit 76b539b

Please sign in to comment.