Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/colors/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Colors Example
==================================================

This example was generated with:

$ bashly init
$ bashly add colors
$ bashly generate
170 changes: 170 additions & 0 deletions examples/colors/colorly
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#!/usr/bin/env bash
# This script was generated by bashly (https://github.com/DannyBen/bashly)
# Modifying it manually is not recommended

# :command.root_command
root_command() {
# :src/root_command.sh
message=${args[message]:-hello colors}

underlined "Message Recevied":
echo
echo " => $(green_bold "$message")"
echo " ==> $(red_bold "$message")"
echo " ===> $(blue_bold "$message")"
echo
}

# :command.version_command
version_command() {
echo "$version"
}

# :command.usage
colorly_usage() {
echo -e "colorly - Sample application that uses the color functions"
echo
echo -e "Usage:"
echo -e " colorly [MESSAGE] [options]"
echo


if [[ -n $long_usage ]]; then
echo -e "Options:"
# :command.usage_fixed_flags
echo " --help, -h"
echo -e " Show this help"
echo
echo " --version"
echo -e " Show version number"
echo

# :command.usage_args
echo -e "Arguments:"

# :argument.usage
echo " MESSAGE"
echo " Message to show [default: hello colors]"
echo



fi
}


# :command.inspect_args
inspect_args() {
echo args:
for k in "${!args[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
}

# :command.user_lib
# :src/lib/colors.sh
# ---
# Color functions
# This file is a part of Bashly standard library
#
# Usage:
# Use any of the functions below to color or format a portion of a string.
#
# echo "before $(red this is red) after"
# echo "before $(green_bold this is green_bold) after"
#
# ---

red() { echo -e "\e[31m$*\e[0m" ; }
green() { echo -e "\e[32m$*\e[0m" ; }
yellow() { echo -e "\e[33m$*\e[0m" ; }
blue() { echo -e "\e[34m$*\e[0m" ; }
magenta() { echo -e "\e[35m$*\e[0m" ; }
cyan() { echo -e "\e[36m$*\e[0m" ; }
bold() { echo -e "\e[1m$*\e[0m" ; }
underlined() { echo -e "\e[4m$*\e[0m" ; }
red_bold() { echo -e "\e[1;31m$*\e[0m" ; }
green_bold() { echo -e "\e[1;32m$*\e[0m" ; }
yellow_bold() { echo -e "\e[1;33m$*\e[0m" ; }
blue_bold() { echo -e "\e[1;34m$*\e[0m" ; }
magenta_bold() { echo -e "\e[1;35m$*\e[0m" ; }
cyan_bold() { echo -e "\e[1;36m$*\e[0m" ; }
red_underlined() { echo -e "\e[4;31m$*\e[0m" ; }
green_underlined() { echo -e "\e[4;32m$*\e[0m" ; }
yellow_underlined() { echo -e "\e[4;33m$*\e[0m" ; }
blue_underlined() { echo -e "\e[4;34m$*\e[0m" ; }
magenta_underlined() { echo -e "\e[4;35m$*\e[0m" ; }
cyan_underlined() { echo -e "\e[4;36m$*\e[0m" ; }



# :command.command_functions

# :command.parse_args
parse_args() {
# :command.fixed_flag_filter
case "$1" in
--version | -v )
version_command
exit 1
;;

--help | -h )
long_usage=yes
colorly_usage
exit 1
;;

esac
# :command.command_filter
action=root
# :command.required_args_filter
# :command.required_flags_filter
# :command.parse_args_while
while [[ $# -gt 0 ]]; do
key="$1"
case "$key" in

-* )
echo -e "invalid option: $key"
exit 1
;;

* )
# :command.parse_args_case
if [[ ! ${args[message]} ]]; then
args[message]=$1
shift
else
echo -e "invalid argument: $key"
exit 1
fi
;;

esac
done
}


# :command.initialize
initialize() {
version="0.1.0"
long_usage=''
set -e
}

# :command.run
run() {
declare -A args
parse_args "$@"

if [[ ${args[--version]} ]]; then
version_command
elif [[ ${args[--help]} ]]; then
long_usage=yes
colorly_usage
elif [[ $action == "root" ]]; then
root_command
fi
}

initialize
run "$@"
7 changes: 7 additions & 0 deletions examples/colors/src/bashly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: colorly
help: Sample application that uses the color functions
version: 0.1.0

args:
- name: message
help: "Message to show [default: hello colors]"
32 changes: 32 additions & 0 deletions examples/colors/src/lib/colors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# ---
# Color functions
# This file is a part of Bashly standard library
#
# Usage:
# Use any of the functions below to color or format a portion of a string.
#
# echo "before $(red this is red) after"
# echo "before $(green_bold this is green_bold) after"
#
# ---

red() { echo -e "\e[31m$*\e[0m" ; }
green() { echo -e "\e[32m$*\e[0m" ; }
yellow() { echo -e "\e[33m$*\e[0m" ; }
blue() { echo -e "\e[34m$*\e[0m" ; }
magenta() { echo -e "\e[35m$*\e[0m" ; }
cyan() { echo -e "\e[36m$*\e[0m" ; }
bold() { echo -e "\e[1m$*\e[0m" ; }
underlined() { echo -e "\e[4m$*\e[0m" ; }
red_bold() { echo -e "\e[1;31m$*\e[0m" ; }
green_bold() { echo -e "\e[1;32m$*\e[0m" ; }
yellow_bold() { echo -e "\e[1;33m$*\e[0m" ; }
blue_bold() { echo -e "\e[1;34m$*\e[0m" ; }
magenta_bold() { echo -e "\e[1;35m$*\e[0m" ; }
cyan_bold() { echo -e "\e[1;36m$*\e[0m" ; }
red_underlined() { echo -e "\e[4;31m$*\e[0m" ; }
green_underlined() { echo -e "\e[4;32m$*\e[0m" ; }
yellow_underlined() { echo -e "\e[4;33m$*\e[0m" ; }
blue_underlined() { echo -e "\e[4;34m$*\e[0m" ; }
magenta_underlined() { echo -e "\e[4;35m$*\e[0m" ; }
cyan_underlined() { echo -e "\e[4;36m$*\e[0m" ; }
8 changes: 8 additions & 0 deletions examples/colors/src/root_command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
message=${args[message]:-hello colors}

underlined "Message Recevied":
echo
echo " => $(green_bold "$message")"
echo " ==> $(red_bold "$message")"
echo " ===> $(blue_bold "$message")"
echo
7 changes: 7 additions & 0 deletions examples/colors/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -x

bashly generate

./colorly
8 changes: 8 additions & 0 deletions examples/config-ini/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Config Example
==================================================

This example was generated with:

$ bashly init
$ bashly add config
$ bashly generate
3 changes: 3 additions & 0 deletions examples/config-ini/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hello = world
bashly = works

Loading