Skip to content

Commit

Permalink
add is-true, is-false
Browse files Browse the repository at this point in the history
  • Loading branch information
siakhooi committed Mar 24, 2023
1 parent eb17b3c commit 6866ca8
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 19 deletions.
26 changes: 19 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ build:
./build.sh

test-man:
pandoc src/md/suffix.1.md -s -t man | man -l -
pandoc src/md/prefix.1.md -s -t man | man -l -
# pandoc src/md/suffix.1.md -s -t man | man -l -
# pandoc src/md/prefix.1.md -s -t man | man -l -
pandoc src/md/is-true.1.md -s -t man | man -l -

test-install:
sudo apt install -f ./siakhooi-textutils_1.2.0_amd64.deb
Expand All @@ -18,10 +19,21 @@ delete-tags:
terminalizer:
terminalizer render docs/terminalizer-textutils

docker-ubuntu-bash:
docker run --rm -it -w /working -v $$(pwd):/working ubuntu bash
run-in-container:
# . in-container-init.sh

docker-debian-bash:
docker run --rm -it -w /working -v $$(pwd):/working debian bash
# . in-container-init.sh
test-in-container:
cat /etc/lsb-release | prefix ' >>>>> '
cat /etc/lsb-release | suffix ' >>>>> '
cat /etc/lsb-release | indent ' >>>>> '
is-true yes
is-true Y
is-true on
is-true no
is-true no1
is-false no
is-false N
is-false off
is-false yes
is-false yes1

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# bash-textutils

Package `siakhooi-textutils` to indent line of texts with a prefix.
Package `siakhooi-textutils` to transform or evaluate text.

## Commands

```bash
cat filename1 | indent 'prefix'
cat filename1 | prefix 'prefix'
cat filename1 | suffix 'suffix'

is-true value
is-false value
```

👉Visit [Screenshots](screenshots/Screenshots.md) of each commands.
Expand Down
8 changes: 5 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ cp -vr $SOURCE/bin $TARGET/usr

# Man Pages
mkdir -p $TARGET/usr/share/man/man1/
pandoc $SOURCE/md/prefix.1.md -s -t man | gzip -9 >$TARGET/usr/share/man/man1/prefix.1.gz
pandoc $SOURCE/md/suffix.1.md -s -t man | gzip -9 >$TARGET/usr/share/man/man1/suffix.1.gz
pandoc $SOURCE/md/siakhooi-textutils.1.md -s -t man | gzip -9 >$TARGET/usr/share/man/man1/siakhooi-textutils.1.gz
mkdir -p $TARGET/usr/share/man/man1/
fileList=$(cd $SOURCE/md && find *.1.md | sed 's/.md//')
for file in $fileList; do
pandoc $SOURCE/md/$file.md -s -t man | gzip -9 >$TARGET/usr/share/man/man1/$file.gz
done

## Create links
(
Expand Down
2 changes: 1 addition & 1 deletion in-container-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ yes | unminimize

apt install -y man-db

apt install -y ./siakhooi-textutils_1.2.0_amd64.deb
apt install -y ./siakhooi-textutils_1.3.0_amd64.deb
4 changes: 2 additions & 2 deletions src/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: siakhooi-textutils
Version: 1.2.0
Version: 1.3.0
Maintainer: Siak Hooi <siakhooi@gmail.com>
Depends: coreutils, bash
Depends: coreutils, bash, findutils
Architecture: amd64
Homepage: <https://github.com/siakhooi/bash-textutils>
Description: commands to transform line of texts.
14 changes: 14 additions & 0 deletions src/bin/is-false
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

[[ $# -ne 1 ]] && exit 1

T=$(echo "$*" | xargs | tr '[:lower:]' '[:upper:]')

[[ $T == 'N' ]] && exit 0
[[ $T == 'NO' ]] && exit 0
[[ $T == 'F' ]] && exit 0
[[ $T == 'FALSE' ]] && exit 0
[[ $T == 'OFF' ]] && exit 0
[[ $T == '0' ]] && exit 0

exit 1
14 changes: 14 additions & 0 deletions src/bin/is-true
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

[[ $# -ne 1 ]] && exit 1

T=$(echo "$*" | xargs | tr '[:lower:]' '[:upper:]')

[[ $T == 'Y' ]] && exit 0
[[ $T == 'YES' ]] && exit 0
[[ $T == 'T' ]] && exit 0
[[ $T == 'TRUE' ]] && exit 0
[[ $T == 'ON' ]] && exit 0
[[ $T == '1' ]] && exit 0

exit 1
36 changes: 36 additions & 0 deletions src/md/is-false.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
% IS-FALSE(1) Siak Hooi TextUtils 1.1.0 |Text Utils
% Siak Hooi
% March 2023

# NAME
is-false - check if a value is false/no/off/N/F/0

# SYNOPSIS
**is-false** value

# DESCRIPTION
Check if a value is false/no/off/N/F/0, case insensitively, return 0, otherwise return 1.

# EXAMPLES
$ is-false off && echo yes
: yes

$ is-false on || echo no
: no

# EXIT CODE

**0**
: if value is one of the following (case insensitive): false, no, off, N, F, 0

**1**
: if there are 0 argument, or more than 1 argument, or the value is not one of the above.

# LICENSE
MIT

# BUGS
Report bugs at https://github.com/siakhooi/bash-textutils/issues.

# SEE ALSO
siakhooi-textutils(1), is-true(1)
36 changes: 36 additions & 0 deletions src/md/is-true.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
% IS-TRUE(1) Siak Hooi TextUtils 1.1.0 |Text Utils
% Siak Hooi
% March 2023

# NAME
is-true - check if a value is true/yes/on/Y/T/1

# SYNOPSIS
**is-true** value

# DESCRIPTION
Check if a value is true/yes/on/Y/T/1, case insensitively, return 0, otherwise return 1.

# EXAMPLES
$ is-true on && echo yes
: yes

$ is-true off || echo no
: no

# EXIT CODE

**0**
: if value is one of the following (case insensitive): true, yes, on, Y, T, 1

**1**
: if there are 0 argument, or more than 1 argument, or the value is not one of the above.

# LICENSE
MIT

# BUGS
Report bugs at https://github.com/siakhooi/bash-textutils/issues.

# SEE ALSO
siakhooi-textutils(1), is-false(1)
13 changes: 8 additions & 5 deletions src/md/siakhooi-textutils.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
# NAME
**prefix** - add a prefix to all lines of text.\
**indent** - add a prefix to all lines of text.\
**suffix** - add a suffix to all lines of text.

**suffix** - add a suffix to all lines of text.\
**is-true** - check if a value is true/yes/on/Y/T/1.\
**is-false** - check if a value is false/no/off/N/F/0.\

# SYNOPSIS
**prefix** prefix\
**indent** prefix\
**suffix** suffix
**suffix** suffix\
**is-true** value\
**is-false** value

# DESCRIPTION
Collection of programs to tranform line of texts.
Collection of programs related to text transformations and evaluations.

# LICENSE
MIT
Expand All @@ -23,4 +26,4 @@ MIT
Report bugs at https://github.com/siakhooi/bash-textutils/issues.

# SEE ALSO
prefix(1), suffix(1)
prefix(1), suffix(1), is-true(1), is-false(1)

0 comments on commit 6866ca8

Please sign in to comment.