Skip to content

Latest commit

 

History

History
516 lines (330 loc) · 9.66 KB

README.md

File metadata and controls

516 lines (330 loc) · 9.66 KB



Shell Check

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.


How to use it?

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.

Features

respect.message

respect.message "param1"
  • param1 Message

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.message "Normal message"

respect.message

respect.message.red

respect.message.red "param1"
  • param1 Message

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.message.red "Red message"

respect.message.red

respect.message.green

respect.message.green "param1"
  • param1 Message

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.message.green "Green message"

respect.message.green

respect.message.blue

respect.message.blue "param1"
  • param1 Message

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.message.blue "Blue message"

respect.message.blue

respect.message.yellow

respect.message.yellow "param1"
  • param1 Message

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.message.yellow "Yellow message"

respect.message.yellow

respect.message.error

respect.message.error "param1"
  • param1 Message

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.message.error "Error"

respect.message.error

respect.message.success

respect.message.success "param1"
  • param1 Message

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.message.success "Success"

respect.message.success

respect.message.info

respect.message.info "param1"
  • param1 Message

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.message.info "Info"

respect.message.info

respect.message.warning

respect.message.warning "param1"
  • param1 Message

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.message.warning "Warning"

respect.message.warning

respect.title

respect.title "param1"
  • param1 Title

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.title "Title"

respect.title

respect.process

respect.process "param1" "param2"
  • param1 Process label
  • param2 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"

respect.process

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.process

respect.prepend.process

respect.prepend.process "param1" "param2"
  • param1 Process label
  • param2 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"

respect.prepend.process

If the callback execution fails (it returns 1).

#!/bin/bash

. /path/to/respect.sh

respect.prepend.process "Processing something" "callback"

respect.prepend.process

respect.label

respect.label "param1" "param2"
  • param1 Label
  • param2 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

respect.label.ln

respect.label.ln "param1" "param2"
  • param1 Label
  • param2 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.label.ln

respect.root_is_required

respect.root_is_required "param1"
  • param1 (Optional) Message

Sample:

#!/bin/bash

. /path/to/respect.sh

respect.root_is_required

respect.root_is_required

respect.dir_exists

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

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

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

respect.question.yesno "param1" "param2"
  • param1 Question string.
  • param2 (Optional) Default answer. It could be y or n. If not present, the default answer is n.

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]: 

Contributing 🚀

  • 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.