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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 69 additions & 5 deletions alf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# This script was generated by bashly 1.2.6 (https://bashly.dannyb.co)
# This script was generated by bashly 1.2.7 (https://bashly.dannyb.co)
# Modifying it manually is not recommended

# :wrapper.bash3_bouncer
Expand Down Expand Up @@ -347,6 +347,20 @@ normalize_input() {
done
}

# :command.inspect_args
inspect_args() {
if ((${#args[@]})); then
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
echo args:
for k in "${sorted_keys[@]}"; do
echo "- \${args[$k]} = ${args[$k]}"
done
else
echo args: none
fi

}

# :command.user_lib
# src/lib/colors.sh
print_in_color() {
Expand All @@ -365,20 +379,29 @@ yellow() { print_in_color "\e[33m" "$*"; }
blue() { print_in_color "\e[34m" "$*"; }
magenta() { print_in_color "\e[35m" "$*"; }
cyan() { print_in_color "\e[36m" "$*"; }
black() { print_in_color "\e[30m" "$*"; }
white() { print_in_color "\e[37m" "$*"; }

bold() { print_in_color "\e[1m" "$*"; }
underlined() { print_in_color "\e[4m" "$*"; }

red_bold() { print_in_color "\e[1;31m" "$*"; }
green_bold() { print_in_color "\e[1;32m" "$*"; }
yellow_bold() { print_in_color "\e[1;33m" "$*"; }
blue_bold() { print_in_color "\e[1;34m" "$*"; }
magenta_bold() { print_in_color "\e[1;35m" "$*"; }
cyan_bold() { print_in_color "\e[1;36m" "$*"; }
black_bold() { print_in_color "\e[1;30m" "$*"; }
white_bold() { print_in_color "\e[1;37m" "$*"; }

red_underlined() { print_in_color "\e[4;31m" "$*"; }
green_underlined() { print_in_color "\e[4;32m" "$*"; }
yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
blue_underlined() { print_in_color "\e[4;34m" "$*"; }
magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
cyan_underlined() { print_in_color "\e[4;36m" "$*"; }
black_underlined() { print_in_color "\e[4;30m" "$*"; }
white_underlined() { print_in_color "\e[4;37m" "$*"; }

# src/lib/find_config.sh
find_config() {
Expand Down Expand Up @@ -556,6 +579,7 @@ save_config() {
# :command.function
alf_connect_command() {

# src/connect_command.sh
repo=${args[repo]}
force=${args[--yes]}
force_ssh=${args[--ssh]}
Expand Down Expand Up @@ -646,6 +670,7 @@ alf_connect_command() {
# :command.function
alf_download_command() {

# src/download_command.sh
find_config

if [[ ! -f $rc_file ]]; then
Expand All @@ -665,6 +690,7 @@ alf_download_command() {
# :command.function
alf_upload_command() {

# src/upload_command.sh
find_config

if [[ ! -f $rc_file ]]; then
Expand All @@ -683,27 +709,31 @@ alf_upload_command() {
# :command.function
alf_generate_command() {

# src/generate_command.sh
generate_config

}

# :command.function
alf_save_command() {

# src/save_command.sh
save_config

}

# :command.function
alf_edit_command() {

# src/edit_command.sh
find_config
${EDITOR:-vi} "$config_file"
}

# :command.function
alf_which_command() {

# src/which_command.sh
code=${args[code]}
subcode=${args[subcode]}

Expand Down Expand Up @@ -740,13 +770,15 @@ alf_which_command() {
# :command.function
alf_upgrade_command() {

# src/upgrade_command.sh
exec bash <(curl -s https://raw.githubusercontent.com/DannyBen/alf/master/setup)

}

# :command.function
alf_info_command() {

# src/info_command.sh
find_config

if [[ -d "$repo_path/.git" ]]; then
Expand Down Expand Up @@ -947,9 +979,14 @@ alf_connect_parse_requirements() {
done

# :command.dependencies_filter
missing_deps=
# :dependency.filter
if ! command -v git >/dev/null 2>&1; then
printf "missing dependency: git\n" >&2
missing_deps=1
fi

if [[ -n $missing_deps ]]; then
exit 1
fi

Expand Down Expand Up @@ -1005,6 +1042,7 @@ alf_connect_parse_requirements() {

esac
done

# :command.required_args_filter
if [[ -z ${args['repo']+x} ]]; then
printf "missing required argument: REPO\nusage: alf connect REPO [OPTIONS]\n" >&2
Expand Down Expand Up @@ -1034,9 +1072,14 @@ alf_download_parse_requirements() {
done

# :command.dependencies_filter
missing_deps=
# :dependency.filter
if ! command -v git >/dev/null 2>&1; then
printf "missing dependency: git\n" >&2
missing_deps=1
fi

if [[ -n $missing_deps ]]; then
exit 1
fi

Expand Down Expand Up @@ -1086,9 +1129,14 @@ alf_upload_parse_requirements() {
done

# :command.dependencies_filter
missing_deps=
# :dependency.filter
if ! command -v git >/dev/null 2>&1; then
printf "missing dependency: git\n" >&2
missing_deps=1
fi

if [[ -n $missing_deps ]]; then
exit 1
fi

Expand Down Expand Up @@ -1307,6 +1355,7 @@ alf_which_parse_requirements() {

esac
done

# :command.required_args_filter
if [[ -z ${args['code']+x} ]]; then
printf "missing required argument: CODE\nusage: alf which CODE [SUBCODE]\n" >&2
Expand Down Expand Up @@ -1336,9 +1385,14 @@ alf_upgrade_parse_requirements() {
done

# :command.dependencies_filter
missing_deps=
# :dependency.filter
if ! command -v curl >/dev/null 2>&1; then
printf "missing dependency: curl\n" >&2
missing_deps=1
fi

if [[ -n $missing_deps ]]; then
exit 1
fi

Expand Down Expand Up @@ -1388,9 +1442,14 @@ alf_info_parse_requirements() {
done

# :command.dependencies_filter
missing_deps=
# :dependency.filter
if ! command -v git >/dev/null 2>&1; then
printf "missing dependency: git\n" >&2
missing_deps=1
fi

if [[ -n $missing_deps ]]; then
exit 1
fi

Expand Down Expand Up @@ -1426,6 +1485,11 @@ initialize() {
long_usage=''
set -e

# :command.globals
declare -g -A args=()
declare -g -a input=()

# src/initialize.sh
aliases_file=${ALF_ALIASES_FILE:-~/.bash_aliases}
rc_file=${ALF_RC_FILE:-~/.alfrc}
set -e
Expand All @@ -1434,8 +1498,6 @@ initialize() {

# :command.run
run() {
declare -g -A args=()
declare -g -a input=()
normalize_input "$@"
parse_requirements "${input[@]}"

Expand All @@ -1452,5 +1514,7 @@ run() {
esac
}

initialize
run "$@"
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
initialize
run "$@"
fi
15 changes: 7 additions & 8 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ section() {
printf "\n=== %s\n" "$(green_bold "$@")"
}

copy() {
printf "%s => %s\n" "$(blue "$(printf '%-25s' "$1")")" "$2"
cp "$1" "$2"
}

sudo_copy() {
printf "%s => %s\n" "$(blue "$(printf '%-25s' "$1")")" "$2"
$sudo cp "$1" "$2"

if [[ -n "$3" ]]; then
$sudo install -m "$3" "$1" "$2"
else
$sudo install "$1" "$2"
fi
}

copy_executable() {
sudo_copy "$1" "/usr/local/bin/"
$sudo chmod a+x "/usr/local/bin/$1"
sudo_copy "$1" "/usr/local/bin/" "755"
}

copy_man() {
Expand Down
9 changes: 9 additions & 0 deletions src/lib/colors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,26 @@ yellow() { print_in_color "\e[33m" "$*"; }
blue() { print_in_color "\e[34m" "$*"; }
magenta() { print_in_color "\e[35m" "$*"; }
cyan() { print_in_color "\e[36m" "$*"; }
black() { print_in_color "\e[30m" "$*"; }
white() { print_in_color "\e[37m" "$*"; }

bold() { print_in_color "\e[1m" "$*"; }
underlined() { print_in_color "\e[4m" "$*"; }

red_bold() { print_in_color "\e[1;31m" "$*"; }
green_bold() { print_in_color "\e[1;32m" "$*"; }
yellow_bold() { print_in_color "\e[1;33m" "$*"; }
blue_bold() { print_in_color "\e[1;34m" "$*"; }
magenta_bold() { print_in_color "\e[1;35m" "$*"; }
cyan_bold() { print_in_color "\e[1;36m" "$*"; }
black_bold() { print_in_color "\e[1;30m" "$*"; }
white_bold() { print_in_color "\e[1;37m" "$*"; }

red_underlined() { print_in_color "\e[4;31m" "$*"; }
green_underlined() { print_in_color "\e[4;32m" "$*"; }
yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
blue_underlined() { print_in_color "\e[4;34m" "$*"; }
magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
cyan_underlined() { print_in_color "\e[4;36m" "$*"; }
black_underlined() { print_in_color "\e[4;30m" "$*"; }
white_underlined() { print_in_color "\e[4;37m" "$*"; }