Skip to content

Commit

Permalink
fix: yaml parameters wrap in double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
t0pd4wn committed Mar 13, 2024
1 parent d02a947 commit 1774e6d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/code/modules/loco_background.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ loco::background_manager(){
# in case $ACTION is "update" and the old background is kept
# set $final_path to the previous background path
if [[ -z "${final_path-}" ]]; then
previous_bg_url=$(yaml::get "${INSTANCE_YAML}" '.style.background')
previous_bg_url=$(yaml::get "${INSTANCE_YAML}" ".style.background")
if [[ -n "${previous_bg_url}" ]]; then
final_path="${previous_bg_url}"
# todo : else retrieve legacy background ?
Expand Down Expand Up @@ -73,7 +73,7 @@ loco::set_background(){
local ab_path=$(pwd)
local assets_path="${PROFILES_DIR}"/"${PROFILE}"/assets/
local profile_bg_path=$(find "${ab_path}"/"${assets_path}" -name 'background.*' 2>/dev/null)
local yaml_bg_url=$(yaml::get "${PROFILE_YAML}" '.style.background')
local yaml_bg_url=$(yaml::get "${PROFILE_YAML}" ".style.background")
local bg_option="${BACKGROUND_URL:-"${yaml_bg_url}"}"
declare -n img_path="${1-}"

Expand Down Expand Up @@ -111,7 +111,7 @@ loco::unset_background(){
local os_default_bg
local os_path
local img_path
local legacy_path=$(yaml::get ${INSTANCE_YAML} ".style.legacy_background")
local legacy_path=$(yaml::get "${INSTANCE_YAML}" ".style.legacy_background")

# if there is a legacy path and if the file still exist
# assign this file to background
Expand Down
18 changes: 12 additions & 6 deletions src/code/modules/loco_multi_profiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ loco::profile_prepare(){
loco::profile_manage_imports "${yaml_temp}"

# list profiles after depackaging
profile_imports=($(yaml::get "${yaml_temp}" ".profiles.import[]"))
# todo: check working state of imports
profile_imports=($(yaml::get_array "${yaml_temp}" ".profiles.import"))
profile_length=${#profile_imports[@]}

if [[ "${profile_length}" -gt 1 ]]; then
Expand All @@ -75,13 +76,15 @@ loco::profile_manage_imports(){
declare -a profiles_to_import
declare -a parent_profiles

profiles_to_import=($(yaml::get "${yaml_temp}" ".profiles.to_import[]"))
# todo: check status of imports
profiles_to_import=($(yaml::get_array "${yaml_temp}" ".profiles.to_import"))

# if there are import profiles to be managed
if [[ -n "${profiles_to_import[@]}" ]]; then
loco::profile_manage_imports_dependencies "${yaml_temp}"
else
parent_profiles=($(yaml::get "${yaml_temp}" ".profiles.parent[]"))
# todo: check status of imports
parent_profiles=($(yaml::get_array "${yaml_temp}" ".profiles.parent"))
# if there are parent profiles, copy them in the import list
if [[ -n "${parent_profiles[@]}" ]]; then
for parent in "${parent_profiles[@]}"; do
Expand All @@ -106,7 +109,8 @@ loco::profile_manage_imports_dependencies(){
local has_profile
local is_parent

profiles_to_import=($(yaml::get "${yaml_temp}" ".profiles.to_import[]"))
# todo: check status of imports
profiles_to_import=($(yaml::get "${yaml_temp}" ".profiles.to_import"))

profiles_length="${#profiles_to_import[@]}"

Expand All @@ -120,7 +124,8 @@ loco::profile_manage_imports_dependencies(){

if [[ -f "${profile_yaml}" ]]; then
# get profile imports from profile yaml
profile_imports=($(yaml::get "${profile_yaml}" ".profiles.import[]"))
# todo: check status of imports
profile_imports=($(yaml::get_array "${profile_yaml}" ".profiles.import"))
else
# if there is no yaml file in the profile, exit loop
msg::debug "" "${profile}" " has no yaml file."
Expand Down Expand Up @@ -170,7 +175,8 @@ loco::profile_manage_imports_dependencies(){
done

# reset to_import list with the child list content
child_profiles=($(yaml::get "${yaml_temp}" ".profiles.child[]"))
# todo: check status of imports
child_profiles=($(yaml::get_array "${yaml_temp}" ".profiles.child"))
for child in "${child_profiles[@]}"; do
yaml::add "${yaml_temp}" ".profiles.to_import" "${child}"
yaml::delete "${yaml_temp}" ".profiles.child" "${child}"
Expand Down
2 changes: 1 addition & 1 deletion src/code/modules/loco_overlay.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ loco::overlay_manager(){
local ab_path=$(pwd)
local assets_path="${PROFILES_DIR}"/"${PROFILE}"/assets/
local profile_ovl_path=$(find "${ab_path}"/"${assets_path}" -name 'overlay.png' 2>/dev/null)
local yaml_ovl_path=$(yaml::get "${PROFILE_YAML}" '.style.overlay')
local yaml_ovl_path=$(yaml::get "${PROFILE_YAML}" ".style.overlay")
local ovl_path="${OVERLAY_PATH:-"${yaml_ovl_path}"}"
local local_ovls_path=./src/assets/background-overlays/
local final_path
Expand Down
10 changes: 5 additions & 5 deletions src/code/modules/loco_prompts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ loco::prompt_action(){
########################################
loco::prompt_background(){
local profile_bkg
profile_bkg=$(yaml::get "${PROFILE_YAML}" '.style.background')
profile_bkg=$(yaml::get "${PROFILE_YAML}" ".style.background")

# if action "update", check for new profile background
if [[ "${ACTION}" == "update" ]]; then
local watermark_bkg=$(yaml::get "${INSTANCE_YAML}" '.style.background')
local watermark_bkg=$(yaml::get "${INSTANCE_YAML}" ".style.background")
if [[ "${watermark_bkg}" != "" ]]; then
msg::prompt "Do you want to change your " "current background " "? (y/n) "
case ${USER_ANSWER:0:1} in
Expand Down Expand Up @@ -61,7 +61,7 @@ loco::prompt_background(){
########################################
loco::prompt_overlay(){
local style_overlay
style_overlay=$(yaml::get "${PROFILE_YAML}" '.style.overlay')
style_overlay=$(yaml::get "${PROFILE_YAML}" ".style.overlay")

if [ -z "${style_overlay:-"${OVERLAY_PATH}"}" ]; then
prompt::build "OVERLAY_PATH" "./src/assets/background-overlays/" "Choose an overlay:" false
Expand Down Expand Up @@ -94,7 +94,7 @@ loco::prompt_profile(){
# THEME
########################################
loco::prompt_theme(){
local profile_style=$(yaml::get "${PROFILE_YAML}" '.style.colors.theme')
local profile_style=$(yaml::get "${PROFILE_YAML}" ".style.colors.theme")
local local_theme=./"${PROFILES_DIR}"/"${PROFILE}"/assets/terminal.conf

# if macos, exit
Expand All @@ -105,7 +105,7 @@ loco::prompt_theme(){

# if action "update", check for existing style
if [[ "${ACTION}" == "update" ]]; then
local watermark_style=$(yaml::get "${INSTANCE_YAML}" '.style.colors.theme')
local watermark_style=$(yaml::get "${INSTANCE_YAML}" ".style.colors.theme")

# if a theme is already set
if [[ -n "${watermark_style}" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions src/code/modules/loco_terminal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ loco::term_conf_set(){

local colors_theme_file=./src/assets/themes/"${THEME}".conf

font_name=$(yaml::get "${PROFILE_YAML}" '.style.fonts.name')
font_name=$(yaml::get "${PROFILE_YAML}" ".style.fonts.name")
if [[ "${ACTION}" == "install" ]] || [[ "${ACTION}" == "update" ]]; then
#statements
font_name="${font_name}"
Expand All @@ -89,7 +89,7 @@ loco::term_conf_set(){
fi
fi

font_size=$(yaml::get "${PROFILE_YAML}" '.style.fonts.size')
font_size=$(yaml::get "${PROFILE_YAML}" ".style.fonts.size")
font_size="${font_size:-"10"}"

if [[ "${LOCO_OSTYPE}" == "macos" ]]; then
Expand Down
6 changes: 3 additions & 3 deletions src/code/modules/loco_watermark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ loco::watermark_action_remove(){
local profile_array
local profile_prefix

PROFILE=$(yaml::get "${INSTANCE_YAML}" '.instance.PROFILE')
CURRENT_USER=$(yaml::get "${INSTANCE_YAML}" '.instance.CURRENT_USER')
INSTANCE_PATH=$(yaml::get "${INSTANCE_YAML}" '.instance.INSTANCE_PATH')
PROFILE=$(yaml::get "${INSTANCE_YAML}" ".instance.PROFILE")
CURRENT_USER=$(yaml::get "${INSTANCE_YAML}" ".instance.CURRENT_USER")
INSTANCE_PATH=$(yaml::get "${INSTANCE_YAML}" ".instance.INSTANCE_PATH")

profile_array=(${PROFILE})

Expand Down

0 comments on commit 1774e6d

Please sign in to comment.