Giter Club home page Giter Club logo

respect-shell's Introduction

Shell Check

respect.message

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.

respect-shell's People

Contributors

diogocavilha avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.