diff --git a/data/shell-completion/flameshot b/data/shell-completion/flameshot.bash_zsh similarity index 100% rename from data/shell-completion/flameshot rename to data/shell-completion/flameshot.bash_zsh diff --git a/data/shell-completion/flameshot.fish b/data/shell-completion/flameshot.fish new file mode 100644 index 00000000..07d96a1e --- /dev/null +++ b/data/shell-completion/flameshot.fish @@ -0,0 +1,111 @@ +set -l SUBCOMMANDS gui screen full launcher config + +#################### +# HELPER FUNCTIONS # +#################### + +# Complete the subcommand provided as the first argument. +# The rest of the arguments are the same as fish's `complete`. The option +# '-c flameshot' is implicit. +function __flameshot_complete --argument-names cmd + set -l conditions "__fish_seen_subcommand_from $cmd" + argparse -i "n/condition=" -- $argv[2..] + [ -n "$_flag_n" ] && set -l conditions "$conditions && $_flag_n" + complete -c flameshot $argv -n "$conditions" +end + +# Return success if the command line contains no positional arguments +function __flameshot_no_positional_args + set -l -- args (commandline -po) # cmdline broken up into list + set -l -- cmdline (commandline -p) # single string + set -l -- n (count $args) # number of cmdline tokens + for i in (seq 2 $n) + set -l arg $args[$i] + [ -z "$arg" ] && continue # can be caused by '--' argument + + # If the the last token is a positional argument and there is no + # trailing space, we ignore it + [ "$i" = "$n" ] && [ (string sub -s -1 "$cmdline") != ' ' ] && break + + if string match -rvq '^-' -- "$arg" # doesn't start with - + return 1 + end + end + # contains a '--' argument + string match -r -- '\s--\s' "$cmdline" && return 1 + return 0 +end + +# Complete paths matching $argv +function __flameshot_complete_paths + complete -C"nOnExIsTeNtCoMmAndZIOAGA2329jdbfaFkahDf21234h8z43 $argv" +end + +# Complete the region option +function __flameshot_complete_region --argument subcommand + if [ "$subcommand" = "screen" ] + echo all\tCapture entire screen + else + echo all\tCapture all screens + echo screen0\tCapture screen 0 + echo screen1\tCapture screen 1 + echo screen2\tCapture screen 2 + echo screen3\tCapture screen 3 + end + echo WxH+X+Y\tCustom region in pixels +end + +# Complete screen numbers +function __flameshot_complete_screen_number + echo 0\tScreen 0 + echo 1\tScreen 1 + echo 2\tScreen 2 + echo 3\tScreen 3 +end + +############### +# COMPLETIONS # +############### + +# No subcommand +complete -c flameshot -n __flameshot_no_positional_args -f -a "$SUBCOMMANDS" +complete -c flameshot -l "help" -s "h" -f -d "Display help message" +complete -c flameshot -l "version" -s "v" -f -d "Display version information" -n __flameshot_no_positional_args + +# GUI subcommand +__flameshot_complete gui -f +__flameshot_complete gui -l "path" -s "p" -rk -d "Output file or directory" +__flameshot_complete gui -l "clipboard" -s "c" -f -d "Copy screenshot to the clipboard" +__flameshot_complete gui -l "delay" -s "d" -frk -d "Delay time in milliseconds" +__flameshot_complete gui -l "region" -frk -d "Screenshot region to select (WxH+X+Y)" -a "(__flameshot_complete_region gui)" +__flameshot_complete gui -l "raw" -s "r" -f -d "Print raw PNG capture" +__flameshot_complete gui -l "print-geometry" -s "g" -f -d "Print geometry of the selection" +__flameshot_complete gui -l "upload" -s "u" -f -d "Upload the screenshot" +__flameshot_complete gui -l "pin" -f -d "Pin the screenshot to the screen" +__flameshot_complete gui -l "accept-on-select" -s "s" -f -d "Accept capture as soon as a selection is made" + +# SCREEN subcommand +__flameshot_complete screen -f +__flameshot_complete screen -l "number" -s "n" -frk -d "Screen number (starting from 0)" -a "(__flameshot_complete_screen_number)" +__flameshot_complete screen -l "path" -s "p" -rk -d "Output file or directory" +__flameshot_complete screen -l "clipboard" -s "c" -f -d "Copy screenshot to the clipboard" +__flameshot_complete screen -l "delay" -s "d" -frk -d "Delay time in milliseconds" +__flameshot_complete screen -l "region" -frk -d "Screenshot region to select (WxH+X+Y)" -a "(__flameshot_complete_region screen)" +__flameshot_complete screen -l "raw" -s "r" -f -d "Print raw PNG capture" +__flameshot_complete screen -l "upload" -s "u" -f -d "Upload the screenshot" +__flameshot_complete screen -l "pin" -f -d "Pin the screenshot to the screen" + +# FULL command +__flameshot_complete full -f +__flameshot_complete full -l "path" -s "p" -rk -d "Output file or directory" +__flameshot_complete full -l "clipboard" -s "c" -f -d "Copy screenshot to the clipboard" +__flameshot_complete full -l "delay" -s "d" -frk -d "Delay time in milliseconds" +__flameshot_complete full -l "region" -frk -d "Screenshot region to select (WxH+X+Y)" -a "(__flameshot_complete_region full)" +__flameshot_complete full -l "raw" -s "r" -f -d "Print raw PNG capture" +__flameshot_complete full -l "upload" -s "u" -f -d "Upload the screenshot" + +# LAUNCHER command doesn't have any completions specific to itself + +# CONFIG command -- TODO will be completed in a future version +__flameshot_complete config -f +__flameshot_complete config -l "check" -f -d "Check the configuration for errors" diff --git a/docs/ReleaseNotes_11.0.md b/docs/ReleaseNotes_11.0.md index 69e58985..85feb734 100644 --- a/docs/ReleaseNotes_11.0.md +++ b/docs/ReleaseNotes_11.0.md @@ -63,6 +63,8 @@ We will be in beta for 1-2 weeks depending on what kind of issues are found and - Added an option to enable anti-aliasing when zooming in on a pinned image. +- Added completions for the fish shell + ## Bug Fixes - The border that indicates an object is moveable is no longer saved or copied with the underlying image. diff --git a/packaging/rpm/flameshot.spec b/packaging/rpm/flameshot.spec index 3cc1288c..7a2332e4 100644 --- a/packaging/rpm/flameshot.spec +++ b/packaging/rpm/flameshot.spec @@ -116,6 +116,7 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/*.desktop %endif %{_datadir}/bash-completion/completions/%{name} %{_datadir}/zsh/site-functions/_%{name} +%{_datadir}/fish/vendor_completions.d/%{name}.fish %{_datadir}/dbus-1/interfaces/org.flameshot.Flameshot.xml %{_datadir}/dbus-1/services/org.flameshot.Flameshot.service %{_datadir}/icons/hicolor/*/apps/*.png diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f7ba8b12..97af4e9d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -283,12 +283,15 @@ if (UNIX) configure_file(${CMAKE_SOURCE_DIR}/data/appdata/org.flameshot.Flameshot.metainfo.xml ${CMAKE_CURRENT_BINARY_DIR}/share/metainfo/org.flameshot.Flameshot.metainfo.xml COPYONLY) - configure_file(${CMAKE_SOURCE_DIR}/data/shell-completion/flameshot + configure_file(${CMAKE_SOURCE_DIR}/data/shell-completion/flameshot.bash_zsh ${CMAKE_CURRENT_BINARY_DIR}/share/bash-completion/completions/flameshot COPYONLY) - configure_file(${CMAKE_SOURCE_DIR}/data/shell-completion/flameshot + configure_file(${CMAKE_SOURCE_DIR}/data/shell-completion/flameshot.bash_zsh ${CMAKE_CURRENT_BINARY_DIR}/share/zsh/site-functions/_flameshot COPYONLY) + configure_file(${CMAKE_SOURCE_DIR}/data/shell-completion/flameshot.fish + ${CMAKE_CURRENT_BINARY_DIR}/share/fish/vendor_completions.d/flameshot.fish COPYONLY) + configure_file(${CMAKE_SOURCE_DIR}/data/dbus/org.flameshot.Flameshot.xml ${CMAKE_CURRENT_BINARY_DIR}/share/dbus-1/interfaces/org.flameshot.Flameshot.xml COPYONLY) diff --git a/src/main.cpp b/src/main.cpp index 48208ed0..90a4a800 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -501,7 +501,8 @@ int main(int argc, char* argv[]) AbstractLogger err = AbstractLogger::error(AbstractLogger::Stderr); bool ok = ConfigHandler().checkForErrors(&err); if (ok) { - err << QStringLiteral("No errors detected.\n"); + AbstractLogger::info() + << QStringLiteral("No errors detected.\n"); goto finish; } else { return 1;