Skip to content

Commit

Permalink
Generated new autocompletion scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kallazz committed Oct 6, 2023
1 parent 2b3d8f3 commit 539b075
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 131 deletions.
48 changes: 2 additions & 46 deletions autocompletion_scripts/_makewiz
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,7 @@ _makewiz() {
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:makewiz-command-$line[1]:"
case $line[1] in
(c)
_arguments "${_arguments_options[@]}" \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(cpp)
_arguments "${_arguments_options[@]}" \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(java)
(java)
_arguments "${_arguments_options[@]}" \
'-h[Print help]' \
'--help[Print help]' \
Expand Down Expand Up @@ -90,15 +78,7 @@ _arguments "${_arguments_options[@]}" \
(( CURRENT += 1 ))
curcontext="${curcontext%:*:*}:makewiz-help-command-$line[1]:"
case $line[1] in
(c)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(cpp)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
(java)
(java)
_arguments "${_arguments_options[@]}" \
&& ret=0
;;
Expand Down Expand Up @@ -130,8 +110,6 @@ esac
(( $+functions[_makewiz_commands] )) ||
_makewiz_commands() {
local commands; commands=(
'c:Generate a C Makefile' \
'cpp:Generate a C++ Makefile' \
'java:Generate a Java Makefile' \
'set-compiler:Set the default compiler name' \
'set-executable:Set the default executable name' \
Expand All @@ -140,26 +118,6 @@ _makewiz_commands() {
)
_describe -t commands 'makewiz commands' commands "$@"
}
(( $+functions[_makewiz__c_commands] )) ||
_makewiz__c_commands() {
local commands; commands=()
_describe -t commands 'makewiz c commands' commands "$@"
}
(( $+functions[_makewiz__help__c_commands] )) ||
_makewiz__help__c_commands() {
local commands; commands=()
_describe -t commands 'makewiz help c commands' commands "$@"
}
(( $+functions[_makewiz__cpp_commands] )) ||
_makewiz__cpp_commands() {
local commands; commands=()
_describe -t commands 'makewiz cpp commands' commands "$@"
}
(( $+functions[_makewiz__help__cpp_commands] )) ||
_makewiz__help__cpp_commands() {
local commands; commands=()
_describe -t commands 'makewiz help cpp commands' commands "$@"
}
(( $+functions[_makewiz__default_commands] )) ||
_makewiz__default_commands() {
local commands; commands=()
Expand All @@ -173,8 +131,6 @@ _makewiz__help__default_commands() {
(( $+functions[_makewiz__help_commands] )) ||
_makewiz__help_commands() {
local commands; commands=(
'c:Generate a C Makefile' \
'cpp:Generate a C++ Makefile' \
'java:Generate a Java Makefile' \
'set-compiler:Set the default compiler name' \
'set-executable:Set the default executable name' \
Expand Down
72 changes: 2 additions & 70 deletions autocompletion_scripts/makewiz.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ _makewiz() {
",$1")
cmd="makewiz"
;;
makewiz,c)
cmd="makewiz__c"
;;
makewiz,cpp)
cmd="makewiz__cpp"
;;
makewiz,default)
cmd="makewiz__default"
;;
Expand All @@ -33,12 +27,6 @@ _makewiz() {
makewiz,set-executable)
cmd="makewiz__set__executable"
;;
makewiz__help,c)
cmd="makewiz__help__c"
;;
makewiz__help,cpp)
cmd="makewiz__help__cpp"
;;
makewiz__help,default)
cmd="makewiz__help__default"
;;
Expand All @@ -61,7 +49,7 @@ _makewiz() {

case "${cmd}" in
makewiz)
opts="-c -e -m -t -r -h -V --compiler --executable --math --thread --crypto --cunit --cppunit --help --version c cpp java set-compiler set-executable default help"
opts="-c -e -m -t -r -h -V --compiler --executable --math --thread --crypto --cunit --cppunit --help --version java set-compiler set-executable default help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand Down Expand Up @@ -90,34 +78,6 @@ _makewiz() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
makewiz__c)
opts="-h --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
makewiz__cpp)
opts="-h --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
makewiz__default)
opts="-h --help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
Expand All @@ -133,7 +93,7 @@ _makewiz() {
return 0
;;
makewiz__help)
opts="c cpp java set-compiler set-executable default help"
opts="java set-compiler set-executable default help"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
Expand All @@ -146,34 +106,6 @@ _makewiz() {
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
makewiz__help__c)
opts=""
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
makewiz__help__cpp)
opts=""
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
fi
case "${prev}" in
*)
COMPREPLY=()
;;
esac
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
;;
makewiz__help__default)
opts=""
if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
Expand Down
16 changes: 5 additions & 11 deletions autocompletion_scripts/makewiz.fish
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,17 @@ complete -c makewiz -n "__fish_use_subcommand" -l cunit -d 'Add the CUnit librar
complete -c makewiz -n "__fish_use_subcommand" -l cppunit -d 'Add the CPPUnit library(-lcppunit) to this Makefile'
complete -c makewiz -n "__fish_use_subcommand" -s h -l help -d 'Print help'
complete -c makewiz -n "__fish_use_subcommand" -s V -l version -d 'Print version'
complete -c makewiz -n "__fish_use_subcommand" -f -a "c" -d 'Generate a C Makefile'
complete -c makewiz -n "__fish_use_subcommand" -f -a "cpp" -d 'Generate a C++ Makefile'
complete -c makewiz -n "__fish_use_subcommand" -f -a "java" -d 'Generate a Java Makefile'
complete -c makewiz -n "__fish_use_subcommand" -f -a "set-compiler" -d 'Set the default compiler name'
complete -c makewiz -n "__fish_use_subcommand" -f -a "set-executable" -d 'Set the default executable name'
complete -c makewiz -n "__fish_use_subcommand" -f -a "default" -d 'Show default values'
complete -c makewiz -n "__fish_use_subcommand" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c makewiz -n "__fish_seen_subcommand_from c" -s h -l help -d 'Print help'
complete -c makewiz -n "__fish_seen_subcommand_from cpp" -s h -l help -d 'Print help'
complete -c makewiz -n "__fish_seen_subcommand_from java" -s h -l help -d 'Print help'
complete -c makewiz -n "__fish_seen_subcommand_from set-compiler" -s h -l help -d 'Print help'
complete -c makewiz -n "__fish_seen_subcommand_from set-executable" -s h -l help -d 'Print help'
complete -c makewiz -n "__fish_seen_subcommand_from default" -s h -l help -d 'Print help'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from c; and not __fish_seen_subcommand_from cpp; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "c" -d 'Generate a C Makefile'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from c; and not __fish_seen_subcommand_from cpp; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "cpp" -d 'Generate a C++ Makefile'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from c; and not __fish_seen_subcommand_from cpp; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "java" -d 'Generate a Java Makefile'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from c; and not __fish_seen_subcommand_from cpp; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "set-compiler" -d 'Set the default compiler name'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from c; and not __fish_seen_subcommand_from cpp; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "set-executable" -d 'Set the default executable name'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from c; and not __fish_seen_subcommand_from cpp; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "default" -d 'Show default values'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from c; and not __fish_seen_subcommand_from cpp; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "java" -d 'Generate a Java Makefile'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "set-compiler" -d 'Set the default compiler name'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "set-executable" -d 'Set the default executable name'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "default" -d 'Show default values'
complete -c makewiz -n "__fish_seen_subcommand_from help; and not __fish_seen_subcommand_from java; and not __fish_seen_subcommand_from set-compiler; and not __fish_seen_subcommand_from set-executable; and not __fish_seen_subcommand_from default; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'
6 changes: 2 additions & 4 deletions src/autocompletions/generator.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! This module is responsible for generating autocompletions for the MakeWiz CLI.
//!
//! It generates autocompletion scripts for Bash, Fish, and Zsh.
//! The generated autocompletion scripts are placed in the `completions/` directory
//! The generated autocompletion scripts are placed in the `autocompletion_scripts/` directory
//! within the crate's cargo manifest directory.
//!
//! To generate the scripts, run `cargo run --bin generate_completions`.
Expand All @@ -14,12 +14,10 @@ use std::io::Error;

use makewiz::cli::CLI;

#[allow(dead_code)]
const SHELLS: [Shell; 3] = [Shell::Bash, Shell::Fish, Shell::Zsh];

#[allow(dead_code)]
fn generate_autocompletions() -> Result<(), Error> {
let outdir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("completions/");
let outdir = std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join("autocompletion_scripts/");

let mut cmd = CLI::command();
for shell in SHELLS {
Expand Down

0 comments on commit 539b075

Please sign in to comment.