Skip to content

Commit

Permalink
completions(fish): refactor exercise slug completion (#660)
Browse files Browse the repository at this point in the history
Deduplicate.
  • Loading branch information
ee7 authored Aug 18, 2022
1 parent 5f91265 commit f854784
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions completions/configlet.fish
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
function __fish_configlet_find_dirs
find $argv -maxdepth 1 -mindepth 1 -type d -printf '%P\n' | sort
end

# disable file completions everywhere
complete -c configlet -f

Expand Down Expand Up @@ -30,7 +34,7 @@ complete -c configlet -n "__fish_use_subcommand" -a fmt -d "Format the exercise
complete -c configlet -n "__fish_seen_subcommand_from fmt" -s u -l update -d "Write changes"
complete -c configlet -n "__fish_seen_subcommand_from fmt" -s y -l yes -d "Auto-confirm update"
complete -c configlet -n "__fish_seen_subcommand_from fmt" -s e -l exercise -d "exercise slug" \
-x -a "(find ./exercises/{concept,practice} -maxdepth 1 -mindepth 1 -type d -printf '%P\n' | sort)"
-x -a '(__fish_configlet_find_dirs ./exercises/{concept,practice})'

# sync subcommand
complete -c configlet -n "__fish_use_subcommand" -a sync -d "Check or update Practice Exercise docs, metadata, and tests"
Expand All @@ -42,4 +46,4 @@ complete -c configlet -n "__fish_seen_subcommand_from sync" -l filepaths -d
complete -c configlet -n "__fish_seen_subcommand_from sync" -l metadata -d "Sync metadata only"
complete -c configlet -n "__fish_seen_subcommand_from sync" -l tests -d "For auto-confirming" -x -a "choose include exclude"
complete -c configlet -n "__fish_seen_subcommand_from sync" -s e -l exercise -d "exercise slug" \
-x -a "(find ./exercises/practice -maxdepth 1 -mindepth 1 -type d -printf '%P\n' | sort)"
-x -a '(__fish_configlet_find_dirs ./exercises/practice)'

0 comments on commit f854784

Please sign in to comment.