Command line auto-completion - further enhancements
authorColin Clark <colin.clark@cclark.uk>
Sun, 14 Apr 2024 15:54:41 +0000 (16:54 +0100)
committerColin Clark <colin.clark@cclark.uk>
Sun, 14 Apr 2024 15:54:41 +0000 (16:54 +0100)
- Include auto-completion for remaining options.
- Fix some text errors

auto-complete/geeqie
src/main.cc
src/remote.cc

index ad59fce..1fc4aae 100755 (executable)
@@ -2,43 +2,47 @@
 
 file_types='@(3fr|ani|arw|avif|bmp|cr2|cr3|crw|cur|dds|djvu|dng|erf|gif|heic|heif|ico|jp2|jpe[g]||jpegxl|jps|kdc|mef|mos|mpo|mrw|nef|orf|pbm|pdf|pgm|pnm|ppm|pef|png|psd|qif|qtif|raf|raw|rw2|scr|sr2|srf|svg[z]|tga|targa|tif[f]|webp|xbm|xpm|gqv|xml|xmp)'
 
+actions='About AddMark0 AddMark1 AddMark2 AddMark3 AddMark4 AddMark5 AddMark6 AddMark7 AddMark8 AddMark9 AlterNone Animate Back ClearMarks CloseWindow ColorProfile0 ColorProfile1 ColorProfile2 ColorProfile3 ColorProfile4 ColorProfile5 ConnectZoom100 ConnectZoom200 ConnectZoom25 ConnectZoom300 ConnectZoom33 ConnectZoom400 ConnectZoom50 ConnectZoomFillHor ConnectZoomFillVert ConnectZoomFit ConnectZoomIn ConnectZoomOut Copy CopyPath CopyPathUnquoted CutPath Delete DeleteWindow DrawRectangle Escape ExifRotate ExifWin FilterMark0 FilterMark1 FilterMark2 FilterMark3 FilterMark4 FilterMark5 FilterMark6 FilterMark7 FilterMark8 FilterMark9 FindDupes FirstImage FirstPage Flip FloatTools FolderTree Forward FullScreen Grayscale HelpChangeLog HelpContents HelpKbd HelpNotes HelpSearch HelpShortcuts HideBars HideSelectableToolbars HideTools HistogramChanB HistogramChanCycle HistogramChanG HistogramChanR HistogramChanRGB HistogramChanV HistogramModeCycle HistogramModeLin HistogramModeLog Home IgnoreAlpha ImageBack ImageForward ImageHistogram ImageOverlay ImageOverlayCycle IntMark0 IntMark1 IntMark2 IntMark3 IntMark4 IntMark5 IntMark6 IntMark7 IntMark8 IntMark9 KeywordAutocomplete LastImage LastPage LayoutConfig LogWindow Maintenance Mark0 Mark1 Mark2 Mark3 Mark4 Mark5 Mark6 Mark7 Mark8 Mark9 Mirror Move NewCollection NewFolder NewWindow NewWindowDefault NewWindowFromCurrent NextImage NextPage OpenArchive OpenCollection OpenRecent OpenWith OverUnderExposed PanView PermanentDelete Plugins Preferences PrevImage PrevPage Print Quit Rating0 Rating1 Rating2 Rating3 Rating4 Rating5 RatingM1 RectangularSelection Refresh Rename RenameWindow ResetMark0 ResetMark1 ResetMark2 ResetMark3 ResetMark4 ResetMark5 ResetMark6 ResetMark7 ResetMark8 ResetMark9 Rotate180 RotateCCW RotateCW SBar SBarSort SaveMetadata Search SearchAndRunCommand SelectAll SelectInvert SelectMark0 SelectMark1 SelectMark2 SelectMark3 SelectMark4 SelectMark5 SelectMark6 SelectMark7 SelectMark8 SelectMark9 SelectNone SetMark0 SetMark1 SetMark2 SetMark3 SetMark4 SetMark5 SetMark6 SetMark7 SetMark8 SetMark9 ShowFileFilter ShowInfoPixel ShowMarks SlideShow SlideShowFaster SlideShowPause SlideShowSlower SplitDownPane SplitHorizontal SplitNextPane SplitPaneSync SplitPreviousPane SplitQuad SplitSingle SplitTriple SplitUpPane SplitVertical StereoAuto StereoCross StereoCycle StereoOff StereoSBS Thumbnails ToggleMark0 ToggleMark1 ToggleMark2 ToggleMark3 ToggleMark4 ToggleMark5 ToggleMark6 ToggleMark7 ToggleMark8 ToggleMark9 UnselMark0 UnselMark1 UnselMark2 UnselMark3 UnselMark4 UnselMark5 UnselMark6 UnselMark7 UnselMark8 UnselMark9 Up UseColorProfiles UseImageProfile ViewIcons ViewInNewWindow ViewList WriteRotation WriteRotationKeepDate Zoom100 Zoom200 Zoom25 Zoom300 Zoom33 Zoom400 Zoom50 ZoomFillHor ZoomFillVert ZoomFit ZoomIn ZoomOut ZoomToRectangle'
+
 _geeqie()
 {
        local cur prev
        _init_completion -s || return
 
-       case $prev in
-               :)
-                       case ${COMP_WORDS[1]} in
-                               --cache-render | --cache-render-recurse | --cache-render-shared-recurse | --get-filelist | --get-filelist-recurse | --slideshow-recurse)
-                                       compopt -o nospace
-                                       _filedir -d
-                                       return
-                                       ;;
-                               --config-load)
-                                       compopt -o nospace
-                                       _filedir xml
-                                       return
-                                       ;;
-                               --file | --File | --get-destination | --get-sidecars | --list-add | --selection-add | --selection-remove | --view)
-                                       compopt -o nospace
-                                       _filedir $file_types
-                                       return
-                                       ;;
-                               --get-collection)
-                                       compopt -o nospace
-                                       _filedir gqv
-                                       return
-                                       ;;
-                               --lua)
-                                       compopt -o nospace
-                                       _filedir lua
-                                       return
-                                       ;;
-                       esac
+       case "$prev" in
+               --action)
+                       COMPREPLY=($(compgen -W '$actions' -- "$cur"))
+                       return
+                       ;;
+
+               --cache-maintenance | --cache-render | --cache-render-recurse | --cache-render-shared-recurse | --get-filelist | --get-filelist-recurse | --slideshow-recurse)
+                       _filedir
+                       return
+                       ;;
+
+               --cache-shared | --cache-thumbs)
+                       COMPREPLY=($(compgen -W 'clean clear' -- "$cur"))
+                       return
+                       ;;
+
+               --config-load)
+                       _filedir xml
+                       return
+                       ;;
+
+               --file | --File | --get-destination | --get-sidecars | --list-add | --selection-add | --selection-remove | --view)
+                       _filedir $file_types
+                       return
                        ;;
-               --cache-maintenance)
-                       _filedir -d
+
+               --get-collection)
+                       collection="$(find $HOME/.local/share/geeqie/collections/ -maxdepth 1  -name "*gqv" -exec basename {} \;)"
+                       COMPREPLY=($(compgen -W '$collection' -- "$cur"))
+                       return
+                       ;;
+
+               --lua)
+                       _filedir lua
                        return
                        ;;
        esac
@@ -46,13 +50,12 @@ _geeqie()
        if [[ $cur == -* ]]
        then
                COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur"))
-               [[ ${COMPREPLY-} == *[=:] ]] && compopt -o nospace
+               [[ ${COMPREPLY-} == *[=] ]] && compopt -o nospace
                return
        fi
 
 _filedir $file_types
 
-} &&
-    complete -F _geeqie geeqie
+} &&  complete -F _geeqie geeqie
 
 # ex: filetype=sh
index d933630..f03e1f5 100644 (file)
@@ -600,7 +600,7 @@ static void parse_command_line(gint argc, gchar *argv[])
                 * for use by any remote command that needs it
                 */
                current_dir = g_get_current_dir();
-               pwd = g_strconcat("--PWD:", current_dir, NULL);
+               pwd = g_strconcat("--PWD=", current_dir, NULL);
                remote_list = g_list_prepend(remote_list, pwd);
 
                remote_control(argv[0], remote_list, command_line->path, list, command_line->collection_list);
index 1a21c11..dba0ea3 100644 (file)
@@ -1731,7 +1731,7 @@ static RemoteCommandEntry remote_commands[] = {
        { nullptr, "--cache-render-shared-recurse=", gr_cache_render_standard_recurse, TRUE, FALSE, N_("<folder>"), N_(" render thumbnails recursively (see Help)") },
        { nullptr, "--cache-shared=",         gr_cache_shared,         TRUE,  FALSE, N_("clean|clear"),       N_("clean or clear shared thumbnail cache") },
        { nullptr, "--cache-thumbs=",         gr_cache_thumb,          TRUE,  FALSE, N_("clean|clear"),       N_("clean or clear thumbnail cache") },
-       { "-d",    "--delay=",                gr_slideshow_delay,      TRUE,  FALSE, N_("<[H=][M=][N][.M]>"), N_("set slide show delay to Hrs Mins N.M seconds") },
+       { "-d",    "--delay=",                gr_slideshow_delay,      TRUE,  FALSE, N_("<[H:][M:][N][.M]>"), N_("set slide show delay to Hrs Mins N.M seconds") },
        { nullptr, "--first",                 gr_image_first,          FALSE, FALSE, nullptr,                 N_("first image") },
        { "-f",    "--fullscreen",            gr_fullscreen_toggle,    FALSE, TRUE,  nullptr,                 N_("toggle full screen") },
        { nullptr, "--file=",                 gr_file_load,            TRUE,  FALSE, N_("<FILE>|<URL>"),      N_("open FILE or URL, bring Geeqie window to the top") },
@@ -1949,7 +1949,7 @@ void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path
                                        g_string_append(command, " ");
                                        g_string_append(command, text);
                                        }
-                               if (entry->opt_l && strcmp(entry->opt_l, "file:") == 0)
+                               if (entry->opt_l && strcmp(entry->opt_l, "file=") == 0)
                                        {
                                        blank = TRUE;
                                        }
@@ -1996,7 +1996,7 @@ void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path
                        entry = remote_command_find(text, nullptr);
                        if (entry &&
                            entry->opt_l &&
-                           strcmp(entry->opt_l, "file:") == 0) use_path = FALSE;
+                           strcmp(entry->opt_l, "file=") == 0) use_path = FALSE;
 
                        remote_client_send(rc, text);
 
@@ -2005,12 +2005,12 @@ void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path
 
                if (cmd_list && cmd_list->next)
                        {
-                       prefix = "--list-add:";
+                       prefix = "--list-add=";
                        remote_client_send(rc, "--list-clear");
                        }
                else
                        {
-                       prefix = "file:";
+                       prefix = "file=";
                        }
 
                work = cmd_list;
@@ -2030,7 +2030,7 @@ void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path
                        {
                        gchar *text;
 
-                       text = g_strdup_printf("file:%s", path);
+                       text = g_strdup_printf("file=%s", path);
                        remote_client_send(rc, text);
                        g_free(text);
 
@@ -2046,7 +2046,7 @@ void remote_control(const gchar *arg_exec, GList *remote_list, const gchar *path
                        name = static_cast<const gchar *>(work->data);
                        work = work->next;
 
-                       text = g_strdup_printf("file:%s", name);
+                       text = g_strdup_printf("file=%s", name);
                        remote_client_send(rc, text);
                        g_free(text);