@@ -1562,7 +1562,6 @@ subcommand_list() {
15621562 | cut -d " \" " -f 4 \
15631563 | cut -d " /" -f 8 \
15641564 | grep -iw " \.$subcommands_allowed_extensions " \
1565- | sed " s/\.[$subcommands_allowed_extensions ]*//" \
15661565 | sed " s|$| $real_url $checksum |" \
15671566 | sort -u >> $file_registry
15681567 fi
@@ -1623,7 +1622,7 @@ subcommand_list() {
16231622 # fi
16241623
16251624
1626- # If "refresh-only" is precised in arguments, then it means that we onyl want to refresh the registry and not display the list
1625+ # If "refresh-only" is precised in arguments, then it means that we only want to refresh the registry and not display the list
16271626 if [ " $1 " != " refresh-only" ]; then
16281627
16291628 # Finally display all the subcommands and specify if already installed
@@ -1634,26 +1633,28 @@ subcommand_list() {
16341633 while read -r command ; do
16351634 if [ " $command " != " " ]; then
16361635
1636+ local command_formatted=" $( echo $command | sed ' s/\.\(.*\)/ [\1]/' ) "
1637+
16371638 # Checking if the subcommand is already installed
16381639 if [ -f " $dir_commands /$command " ]; then
16391640
16401641 local command_checksum_known=" $( file_checksum " $dir_commands /$command " ) "
16411642 local command_checksum_remote=" $( file_checksum $( get_config_value $file_registry $command 2) ) "
16421643
16431644 if [ " $command_checksum_known " = " $command_checksum_remote " ]; then
1644- echo " $command $installed "
1645+ echo " $command_formatted $installed "
16451646 else
1646- echo " $command $installed $updatable "
1647+ echo " $command_formatted $installed $updatable "
16471648 fi
16481649 else
1649- echo " $command "
1650+ echo " $command_formatted "
16501651 fi
16511652
16521653
16531654 fi
16541655 done < $list_installed_tmp | sort -ud
16551656
1656- rm -f $list_installed_tmp
1657+ # rm -f $list_installed_tmp
16571658 else
16581659 log_error " no command installed."
16591660 fi
@@ -1699,7 +1700,11 @@ subcommand_get() {
16991700 fi
17001701
17011702 log_success " command '$command ' installed."
1702- log_info " '$NAME_ALIAS $command --help' to display help."
1703+
1704+ # Detect if the command have a help command
1705+ if [ " $( cat $file_command | grep -v ' ^#' | grep ' display_help()' ) " ]; then
1706+ log_info " '$NAME_ALIAS $command --help' to display usage."
1707+ fi
17031708 else
17041709 log_error " command '$command ' not installed."
17051710 fi
@@ -2151,14 +2156,26 @@ install_cli() {
21512156 # Reinstall all automations and completion of the subcommands
21522157 if [ -d " $dir_commands " ]; then
21532158 if [ " $( ls $dir_commands ) " ]; then
2154- for command in " $( ls $dir_commands ) " ; do
2155- for automation in " $( cat $dir_commands /$command | grep create_automation | grep -v ' ^#' | sed ' s/^.*$HELPER //' | sed ' s/$1/' $command ' /' ) " ; do
2156- $automation
2157- done
2158-
2159- for completion in " $( cat $dir_commands /$command | grep create_completion | grep -v ' ^#' | sed ' s/^.*$HELPER //' | sed ' s/$1/' $command ' /' ) " ; do
2160- $completion
2161- done
2159+ for command in $dir_commands /* ; do
2160+
2161+ # echo $command
2162+ # echo $dir_commands/$command
2163+
2164+ local command_name=" $( echo $command | sed ' s|^.*/\(.*\)\..*|\1|' ) "
2165+
2166+ # Ensure the command needs to be initialized
2167+ if [ " $( cat $command | grep ' init_command()' ) " ]; then
2168+
2169+ # Create automations
2170+ for automation in " $( cat $command | grep create_automation | grep -v ' ^#' | sed ' s|^.*$HELPER ||' | sed ' s|$command_name|' $command_name ' |' ) " ; do
2171+ $automation
2172+ done
2173+
2174+ # Create completion
2175+ for completion in " $( cat $command | grep create_completion | grep -v ' ^#' | sed ' s|^.*$HELPER ||' | sed ' s|$command_name|' $command_name ' |' ) " ; do
2176+ $completion
2177+ done
2178+ fi
21622179 done
21632180 fi
21642181 fi
0 commit comments