Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fish shell completion for cement itself. #651

Open
tomclad opened this issue Mar 1, 2023 · 1 comment
Open

Fish shell completion for cement itself. #651

tomclad opened this issue Mar 1, 2023 · 1 comment
Assignees

Comments

@tomclad
Copy link

tomclad commented Mar 1, 2023

System Information

  • Cement Version: 3.0.8
  • Operating System: Linux
  • shell: Fish shell
  • fish version: 3.6.0

request
I request you to include this cement completion file in cement. I am submitting this through issues is because I don't know how to modify and submit PR for cement. I am new to github and programming in general.

I request you to install cement.fish file in users ~/.config/fish/completions/ in future cement realeases.
shellingham package can be used to detect the shell and if shell is found to be fish it can be installed at above location.

Issue
I have been using cement developer tools for creating projects, plugins, extension, etc.

  • E.g. cement generate project

It was tedious to write commands all the time. so I have written fish shell completion for cement.
According to fish shell this completion file only needs to saved at one of the following locations here
I have put my cement completion file at ~/.config/fish/completions
and it works as intended.

as it can be seen from below screenshot.

cement-command-completion-fish

Below script not only supports command completions but also all option completion for cement itself also for generate sub-command.
and also supports option completion for sub-commands of generate sub-command. :-)

Fish shell completion file

# file name cement.fish
set -l cement generate
set -l generate plugin extension script project todo-tutorial


# cement options completion
complete -c cement -n "not __fish_seen_subcommand_from $cement" -x -s h -l help -d 'show this help message and exit'
complete -c cement -n "not __fish_seen_subcommand_from $cement" -r -s d -l debug -d 'full application debug mode'
complete -c cement -n "not __fish_seen_subcommand_from $cement" -r -s q -l quiet -d 'suppress all console output'
complete -c cement -n "not __fish_seen_subcommand_from $cement" -x -s v -l version -d 'show program\'s version number and exit'


# cement commands completion
complete -f -c cement -n "not __fish_seen_subcommand_from $cement" -a generate -d 'generate controller'

## generate options completion
complete -c cement -n "__fish_seen_subcommand_from generate;
and not __fish_seen_subcommand_from $generate" -x -s h -l help -d 'show this help message and exit'

### generate sub-commands options completion
complete -f cement -n "__fish_seen_subcommand_from $generate" -x -s h -l help -d 'show this help message and exit'
complete  cement -n "__fish_seen_subcommand_from $generate" -r -s f -l force -d 'force operation if destination exists'
complete  cement -n "__fish_seen_subcommand_from $generate" -r -s D -l defaults -d 'use all default variable values'
complete  cement -n "__fish_seen_subcommand_from $generate" -r -l clone -d 'clone this template to destination path'

## generate sub-commands completion
complete -f -c cement -n "__fish_seen_subcommand_from generate;and not __fish_seen_subcommand_from $generate" -a project -d 'generate project from template'
complete -f -c cement -n "__fish_seen_subcommand_from generate;and not __fish_seen_subcommand_from $generate" -a plugin -d 'generate plugin from template'
complete -f -c cement -n "__fish_seen_subcommand_from generate;and not __fish_seen_subcommand_from $generate" -a extension -d 'generate extension from template'
complete -f -c cement -n "__fish_seen_subcommand_from generate;and not __fish_seen_subcommand_from $generate" -a script -d 'generate script from template'
complete -f -c cement -n "__fish_seen_subcommand_from generate;and not __fish_seen_subcommand_from $generate" -a todo-tutorial -d 'generate todo-tutorial from template'

above file needs to be saved as follows.
~/.config/fish/completions/cement.fish

cheers. :=)

@derks
Copy link
Member

derks commented Aug 9, 2023

@tomclad thank you for the request. Installing Cement itself would not be able to create this file as we only package the Python library and rely on those tools for install (PIP, etc). That said there are some options:

  • Package maintainers for target OS (DPKG/RPM/Etc) could install this as part of a subpackage... ex: cement-fish-completions or similar.
  • We could consider adding a sub-command like cement autocomplete setup --{fish,bash,zsh,etc} that would make it possible for end user to set it up post-install. From a project perspective this makes the most sense in my opinion.

This request is for Cement devtools, though just wanted to note there are some docs for guides on doing this for apps built on Cement and making note here that we should add something for fish there as well:

@derks derks self-assigned this Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants