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
Add repo completion for zypper #4325
Conversation
@@ -1,7 +1,8 @@ | |||
# completion for zypper | |||
|
|||
set -g __fish_zypper_all_commands shell sh repos lr addrepo ar removerepo rr renamerepo nr modifyrepo mr refresh ref clean services ls addservice as modifyservice ms removeservice rs refresh-services refs install in remove rm verify ve source-install si install-new-recommends inr update up list-updates lu patch list-patches lp dist-upgrade dup patch-check pchk search se info if patch-info pattern-info product-info patches pch packages pa patterns pt products pd what-provides wp addlock al removelock rl locks ll cleanlocks cl versioncmp vcmp targetos tos licenses source-download | |||
set -g __fish_zypper_all_commands shell sh repos lr addrepo ar removerepo rr renamerepo nr modifyrepo mr refresh ref clean cc services ls addservice as modifyservice ms removeservice rs refresh-services refs install in remove rm verify ve source-install si install-new-recommends inr update up list-updates lu patch list-patches lp dist-upgrade dup patch-check pchk search se info if patch-info pattern-info product-info patches pch packages pa patterns pt products pd what-provides wp addlock al removelock rl locks ll cleanlocks cl versioncmp vcmp targetos tos licenses source-download |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, It is better to append new values to lists of this nature. If for no other reason than to make figuring out what changed easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I see why you did it this way. It mimics the other commands which pair the short and long subcommands. Ignore my previous comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Move function into the completion script
-
Ideally port to
string
.
@@ -0,0 +1,3 @@ | |||
function __fish_print_zypp_repos -d "Print repositories of zypper package manager" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is not used anywhere else, can you just stick it in the completion script?
Also I'd appreciate it if this used our string
builtin instead.
Something like
for file in /etc/zypp/repos.d/*.repo
string replace -rf '\[(.*)\]' '$1' <$file
end
(This will match something like [bla]
and replace it with bla
. The "-f" for "--filter" will only use lines where a replacement can be performed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that pacman has a standalone function __fish_print_pacman_repos
, so I thought I should put that into another file... Is it a good idea to write a function __fish_print_repos
and do the distribution detection inside it? Just like __fish_print_packages
?
Also thanks for such detailed explanation! Will replace sed
with string
soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that pacman has a standalone function __fish_print_pacman_repos, so I thought I should put that into another file...
That's also used in other completions (pacman has a bit of a culture of things wrapping it). This one isn't.
Is it a good idea to write a function __fish_print_repos and do the distribution detection inside it? Just like __fish_print_packages?
Please no. I don't like that one as it is, because any completion that uses it wants exactly one of the options. That means the detection is actually unnecessary, and can even be wrong (e.g. if you have apt-cache
installed and try to use pacman
, you'll get the wrong packages).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get it.
@faho Changes done. Please review. |
add subcommand packages to __fish_zypper_repo_commands
Merged, thanks, and sorry for the delay! |
* Add repo completion for zypper * Replace sed with string in __fish_print_zypp_repos * Move function into completion script * Update zypper completion add subcommand packages to __fish_zypper_repo_commands (cherry picked from commit 81becc5)
No description provided.