Skip to content

Commit

Permalink
ADDED: instrspection options
Browse files Browse the repository at this point in the history
  • Loading branch information
AleixMT committed Feb 6, 2024
1 parent f244dda commit c33c2cf
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 26 deletions.
5 changes: 5 additions & 0 deletions data/tools/iochem.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
a add nydesk AutoFirma b bashcolors bclean BFunction branch c calculator changebg cheat checkout chess chrome clean clone cmatrix code commit copyq curl customizer dropbox eclipse EFunction
emojis f fastcommands fetch FFunction gcc gimp git gitcm github githubDesktop gitk gitPristine gitprompt gradle guake h hard hardinfo historyoptimization ideac ideau inkscape ipe ipi ips
jdk17 jekyll k l LFunction loc lolcat m mahjongg matlab mdadm megasync meld mendeley merge mines mvn nano nautilus ncat nedit nemo netflix netTools nmap nodejs notepadqq notflix obsStudio octave okular onedrive opensshServer outlook overleaf p pacman parallel pdfgrep pgadmin php phppgadmin pluma postman presentation prompt psql pull pulseaudio push pycharm pycharmpro pypy3 python3 pytorch R reddit remmina rosegarden rstudio rsync ruby rust s scala scilab screenshots sherlock shotcut shotwell skype slack sonarqube sonicPi soundcloud spotify spreadsheets ssh status steam studio sublime sudoku synaptic sysmontask systemFonts teams teamviewer telegram templates terminal terminalBackground terminator thunderbird tilix tmux tomcat tor traductor transmission trello tumblr tweaks twitch twitter u uget upgrade virtualbox vlc vncviewer vommit whatsapp wikipedia wikit wireshark x xclip youtube youtubeDL youtubeMusic z zoom


142 changes: 116 additions & 26 deletions src/core/functions_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,15 @@ get_next_collisioner()
# - Argument 1, 2, 3... : Arguments for the whole program.
argument_processing()
{
# Used to anotate the state regarding the combination of arguments
local mode=regular

while [ $# -gt 0 ]; do
key="$1"

case "${key}" in
### BEHAVIOURAL ARGUMENTS ###
# Verbosity
-v|--verbose)
FLAG_QUIETNESS=0
;;
Expand All @@ -519,6 +523,7 @@ argument_processing()
FLAG_QUIETNESS=2
;;

# Overwrite or not if installed
-s|--skip|--skip-if-installed)
if [ "${FLAG_MODE}" == "uninstall" ]; then
output_proxy_executioner "You have set to not overwrite features in uninstall mode, this will uninstall only the features that are not installed." "WARNING"
Expand All @@ -529,6 +534,7 @@ argument_processing()
FLAG_OVERWRITE=1
;;

# Error tolerance
-w|--warning|--exit-on-warning)
FLAG_IGNORE_ERRORS=0
;;
Expand All @@ -539,6 +545,7 @@ argument_processing()
FLAG_IGNORE_ERRORS=2
;;

# Clean after installation
# TODO flag autoclean reduce to two states
-c|--clean)
FLAG_AUTOCLEAN=0
Expand All @@ -547,6 +554,7 @@ argument_processing()
FLAG_AUTOCLEAN=2
;;

# Update policy
-k|--keep-system-outdated)
FLAG_UPGRADE=0
;;
Expand All @@ -557,48 +565,55 @@ argument_processing()
FLAG_UPGRADE=2
;;

# Put the installations in favourites task bar
-f|--favorites|--set-favorites)
FLAG_FAVORITES=1
;;
-z|--no-favorites)
FLAG_FAVORITES=0
;;

# Put the installations in startup
-a|--autostart)
FLAG_AUTOSTART=1
;;
-r|--regular)
FLAG_AUTOSTART=0
;;

# Discard installations (used to discard individual installations from flag)
-n|--not)
FLAG_INSTALL=0
;;
-y|--yes)
FLAG_INSTALL=1
;;

# Do not check for match in required privileges for installation
-p|--privilege-check)
FLAG_SKIP_PRIVILEGES_CHECK=0
;;
-P|--skip-privilege-check)
FLAG_SKIP_PRIVILEGES_CHECK=1
;;

# Use the cache (either for saving installations in and to retrieve installations from)
-t|--not-cached)
FLAG_CACHE=0
;;
-T|--cached|--cache|--use-cache)
FLAG_CACHE=1
;;

# Allow the override of the package manager configuration
-O|--Overrides|--allow-overrides)
FLAG_PACKAGE_MANAGER_ALLOW_OVERRIDES=1
;;
-x)
FLAG_PACKAGE_MANAGER_ALLOW_OVERRIDES=0
;;

# Install the dependencies of the installation
# TODO propagate state to each installation, so it follow s the customizer convention of state machine
-d|--dependencies)
FLAG_IGNORE_DEPENDENCIES=0
Expand All @@ -607,85 +622,160 @@ argument_processing()
FLAG_IGNORE_DEPENDENCIES=1
;;

--commands) # Print list of possible arguments and finish the program

### INTROSPECTION AND INFORMATION ###
# Activates introspection mode to take into account order of arguments
inspect)
mode=inspect
;;

features)
if [ "${mode}" != "inspect" ]; then
output_proxy_executioner "\"features\" options can only be used if you specify inspect mode first. Try
with customizer-install inspect features" "ERROR"
fi
local all_arguments+=("${feature_keynames[@]}")
all_arguments+=("${auxiliary_arguments[@]}")
all_arguments+=("${WRAPPERS_KEYNAMES[@]}")
echo "${all_arguments[@]}"
exit 0
;;

--readme|readme|features|FEATURES|FEATURES.sh|features.sh)
# Print list of possible arguments and finish the program
autogen_readme
commands)
if [ "${mode}" != "inspect" ]; then
output_proxy_executioner "\"commands\" options can only be used if you specify inspect mode first. Try
with customizer-install inspect commands" "ERROR"
fi
local all_arguments+=("${feature_keynames[@]}")
all_arguments+=("${auxiliary_arguments[@]}")
all_arguments+=("${WRAPPERS_KEYNAMES[@]}")
echo "${all_arguments[@]}"
exit 0
;;

-h)
output_proxy_executioner "echo ${help_common}${help_simple}" "COMMAND"
exit 0
;;
-H|--help)
output_proxy_executioner "echo ${help_common}${help_arguments}${help_individual_arguments_header}$(autogen_help)${help_wrappers}" "COMMAND"
flags)
if [ "${mode}" != "inspect" ]; then
output_proxy_executioner "\"flags\" options can only be used if you specify inspect mode first. Try
with customizer-install inspect flags" "ERROR"
fi
local all_arguments+=("${auxiliary_arguments[@]}")
echo "${all_arguments[@]}"
exit 0
;;

--show-wrappers)
wrappers)
if [ "${mode}" != "inspect" ]; then
output_proxy_executioner "\"commands\" options can only be used if you specify inspect mode first. Try
with customizer-install inspect commands" "ERROR"
fi
generate_wrappers
display_wrappers
exit 0
;;

--debug)
customizer_prompt
installations)
if [ "${mode}" != "inspect" ]; then
output_proxy_executioner "\"installations\" options can only be used if you specify inspect mode first. Try
with customizer-install inspect installations" "ERROR"
fi
cat "${INSTALLED_FEATURES}"
exit 0
;;

--user|--normal)
add_programs_with_x_permissions 1
initializations)
if [ "${mode}" != "inspect" ]; then
output_proxy_executioner "\"initializations\" options can only be used if you specify inspect mode first. Try
with customizer-install inspect initializations" "ERROR"
fi
cat "${INITIALIZATIONS_PATH}"
exit 0
;;
--root|--superuser|--su)
add_programs_with_x_permissions 0

functions)
if [ "${mode}" != "inspect" ]; then
output_proxy_executioner "\"functions\" options can only be used if you specify inspect mode first. Try
with customizer-install inspect functions" "ERROR"
fi
cat "${FUNCTIONS_PATH}"
exit 0
;;
--ALL|--all|--All)
add_programs_with_x_permissions 2

favorites|favourites)
if [ "${mode}" != "inspect" ]; then
output_proxy_executioner "\"functions\" options can only be used if you specify inspect mode first. Try
with customizer-install inspect functions" "ERROR"
fi
cat "${PROGRAM_FAVORITES_PATH}"
exit 0
;;

keybindings)
if [ "${mode}" != "inspect" ]; then
output_proxy_executioner "\"keybindings\" options can only be used if you specify inspect mode first. Try
with customizer-install inspect keybindings" "ERROR"
fi
cat "${PROGRAM_KEYBINDINGS_PATH}"
exit 0
;;

--flush=favorites)
if [ "${FLAG_MODE}" == "uninstall" ]; then
remove_all_favorites
fi
;;

--flush=keybindings)
if [ "${FLAG_MODE}" == "uninstall" ]; then
remove_all_keybindings
fi
;;

--flush=functions)
if [ "${FLAG_MODE}" == "uninstall" ]; then
remove_all_functions
fi
;;

--flush=initializations)
if [ "${FLAG_MODE}" == "uninstall" ]; then
remove_all_initializations
fi
;;

--flush=structures)
if [ "${FLAG_MODE}" == "uninstall" ]; then
remove_structures
fi
;;

--flush=cache)
if [ "${FLAG_MODE}" == "uninstall" ]; then
rm -Rf "${CACHE_FOLDER}"
fi
;;

--readme|readme|features|FEATURES|FEATURES.sh|features.sh)
# Print list of possible arguments and finish the program
autogen_readme
exit 0
;;

-h)
output_proxy_executioner "echo ${help_common}${help_simple}" "COMMAND"
exit 0
;;
-H|--help)
output_proxy_executioner "echo ${help_common}${help_arguments}${help_individual_arguments_header}$(autogen_help)${help_wrappers}" "COMMAND"
exit 0
;;

--debug)
customizer_prompt
;;

--user|--normal)
add_programs_with_x_permissions 1
;;
--root|--superuser|--su)
add_programs_with_x_permissions 0
;;
--ALL|--all|--All)
add_programs_with_x_permissions 2
;;

*)
# Individual argument
# A feature key name was not detected in the current argument ${key}. Try a wrapper.
Expand Down

0 comments on commit c33c2cf

Please sign in to comment.