A simple shell module for helping you to write better scripts. With this little module you can use some functions that allow you to showing cool messages and performing some verifications as simple as it should be.
What is possible to do once you're using Respect Shell?
Take a look at some features it has by now.
- Messages
- Warnings
- Processes
- Labels
- Functions
You can just git clone this repo and link respect.sh
in your shellscript file, like:
my_file.sh
#!/bin/bash
. /path/to/respect.sh
# You are good to go now.
respect.message "param1"
param1
Message
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.message "Normal message"
respect.message.red "param1"
param1
Message
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.message.red "Red message"
respect.message.green "param1"
param1
Message
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.message.green "Green message"
respect.message.blue "param1"
param1
Message
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.message.blue "Blue message"
respect.message.yellow "param1"
param1
Message
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.message.yellow "Yellow message"
respect.message.error "param1"
param1
Message
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.message.error "Error"
respect.message.success "param1"
param1
Message
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.message.success "Success"
respect.message.info "param1"
param1
Message
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.message.info "Info"
respect.message.warning "param1"
param1
Message
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.message.warning "Warning"
respect.title "param1"
param1
Title
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.title "Title"
respect.process "param1" "param2"
param1
Process labelparam2
Callback
The callback might be a function you've written
Sample:
If the callback execution is succeeded (it returns 0
).
#!/bin/bash
. /path/to/respect.sh
respect.process "Processing something...\t" "callback"
P.S: A succeeded callback execution returns
0
. That's a shellscript rule:0
= true,1
= false. That's a little weird, I know that, but that's how it is, accept it.
If the callback execution fails (it returns 1
).
#!/bin/bash
. /path/to/respect.sh
respect.process "Processing something...\t" "callback"
respect.prepend.process "param1" "param2"
param1
Process labelparam2
Callback
The the callback might be a function you've written
Sample:
If the callback execution is succeeded (it returns 0
).
#!/bin/bash
. /path/to/respect.sh
respect.prepend.process "Processing something" "callback"
If the callback execution fails (it returns 1
).
#!/bin/bash
. /path/to/respect.sh
respect.prepend.process "Processing something" "callback"
respect.label "param1" "param2"
param1
Labelparam2
Value
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.label "Label 1" "Value 1"
respect.label "Label 2" "Value 2"
respect.label "Label 3" "Value 3"
respect.label.ln "param1" "param2"
param1
Labelparam2
Value
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.label.ln "Label line 1" "Value 1"
respect.label.ln "\tLabel line 2" "Value 2"
respect.label.ln "\tLabel line 3" "Value 3"
respect.root_is_required "param1"
param1
(Optional) Message
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.root_is_required
respect.dir_exists "param1"
param1
path
Sample:
#!/bin/bash
. /path/to/respect.sh
if respect.dir_exists "/path/to/directory"
then
# code ...
fi
respect.file_exists "param1"
param1
path
Sample:
#!/bin/bash
. /path/to/respect.sh
if respect.file_exists "/path/to/file"
then
# code ...
fi
respect.window.title "param1"
param1
Window title
Sample:
#!/bin/bash
. /path/to/respect.sh
respect.window.title "This is the window title"
respect.question.yesno "param1" "param2"
param1
Question string.param2
(Optional) Default answer. It could bey
orn
. If not present, the default answer isn
.
Sample:
#!/bin/bash
. /path/to/respect.sh
if respect.question.yesno "Would you like to proceed?" "y"
then
# code ...
fi
Outputs
Yes as default.
respect.question.yesno "Would you like to proceed?" "y"
# Would you like to proceed? [Y/n]:
No as default
respect.question.yesno "Would you like to proceed?" "n"
# Would you like to proceed? [y/N]:
No as default
respect.question.yesno "Would you like to proceed?"
# Would you like to proceed? [y/N]:
- Give this project a star ⭐
- Fork the project.
- Create a branch. (
git checkout -b your-branch-name
). - Make your changes on the branch you've just created.
- Commit it.
- Push it.
- Send your Pull Request.