#50758 Need to enable CLI arg completion
Closed: wontfix 2 years ago by mreynolds. Opened 2 years ago by mreynolds.

Issue Description

On newer platforms, the python CLI arg completion is not working. The tools need to be "registered", see:

https://argcomplete.readthedocs.io/en/latest/

There are a few options. We can enable it by default in the spec file under "%post"

%post
register-python-argcomplete dsctl >> ~/.bashrc
echo "complete -o default -o nospace -F _python_argcomplete dsconf" >> ~/.bashrc
echo "complete -o default -o nospace -F _python_argcomplete dscreate" >> ~/.bashrc
echo "complete -o default -o nospace -F _python_argcomplete dsidm" >> ~/.bashrc

But this updates root's .bashrc file, and this is not undone if you remove the 389-ds-base package.

Or , you set the global policy which impacts all python scripts, but you still need to update the ~/.bashrc file to source the files under /etc/bash_completion.d/

Or, we just release note what to do. But a lot of the CLI design was assuming that auto completion would work out of the box.


I think we should be updating the global completion, it's the best solution here.

Metadata Update from @firstyear:
- Custom field origin adjusted to None
- Custom field reviewstatus adjusted to None

2 years ago

I think we should be updating the global completion, it's the best solution here.

The problem with the global policy is that we still need to update ~/.bashrc to source in the file created by activate-global-python-argcomplete, except it's much more difficult to do so in the specfile %post script, and we are still left with the issue that there is no way to undo it

Foremost, I think we cannot dare to mangle user profiles. And we shouldn't need to anyway, since AFAIU bash-completion adds bindings for sourcing completions from /etc/bash_completion.d which is the place where python-argcomplete puts its own file to be sourced. For us it should be enough to do the magic eval from the argcomplete's docs in a file we place into /etc/bash_completion.d.

Foremost, I think we cannot dare to mangle user profiles. And we shouldn't need to anyway, since AFAIU bash-completion adds bindings for sourcing completions from /etc/bash_completion.d which is the place where python-argcomplete puts its own file to be sourced. For us it should be enough to do the magic eval from the argcomplete's docs in a file we place into /etc/bash_completion.d.

activate-global-python-argcomplete does not work own its own. Trust me I spent all day trying to get it to work

On RHEL 8 this is bashrc file:

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

This does not read/source /etc/bash_completion.d/ I opened a new shell, etc I tried everything. We have to update .bashrc on RHEL 8. On Fedora 30 it all works without having to do anything. But apparently on F31 and RHEL 8 it requires more invasive action :-(

Okay, got it working. Needed to have bash-completion package installed, then activate-global-python-argcomplete worked. Going to put together PR next...

@mreynolds Sorry, maybe I was not clear enough in my message, but (just for the record now) by stating since AFAIU bash-completion adds bindings I implied the bash-completion is required for this to work. I didn't have a strong opinion on this though, since I am OK with approach of people deciding whether to have extended bash completion (not only the readline one) that bash-completion brings, or not.

Commit 4a6a280 relates to this ticket

@mreynolds Sorry, maybe I was not clear enough in my message, but (just for the record now) by stating since AFAIU bash-completion adds bindings I implied the bash-completion is required for this to work. I didn't have a strong opinion on this though, since I am OK with approach of people deciding whether to have extended bash completion (not only the readline one) that bash-completion brings, or not.

What threw me off was that although bash_completion was not installed, I still had /etc/bash_completions.d/ So I thought that was all set up. Anyway thanks for clarifying everything.

Commit 4a6a280 relates to this ticket

53ae896..34c8f85 389-ds-base-1.4.1 -> 389-ds-base-1.4.1

67b12ad..e9e5f97 389-ds-base-1.4.0 -> 389-ds-base-1.4.0

Metadata Update from @mreynolds:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

2 years ago

Metadata Update from @vashirov:
- Custom field rhbz adjusted to https://bugzilla.redhat.com/show_bug.cgi?id=1781131
- Issue status updated to: Open (was: Closed)

2 years ago

Commit ec229f7 relates to this ticket

8fbe976..a9fa0ad 389-ds-base-1.4.1 -> 389-ds-base-1.4.1
e141883..ea0af42 389-ds-base-1.4.0 -> 389-ds-base-1.4.0

Metadata Update from @mhonek:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

2 years ago

Reopening to address Fedora Minimization Objective.
bash-completion should be Recommends instead of Requires.

Metadata Update from @vashirov:
- Issue priority set to: normal
- Issue set to the milestone: 1.4.2
- Issue status updated to: Open (was: Closed)

2 years ago

Metadata Update from @mreynolds:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

2 years ago

Commit 6fd09c4 relates to this ticket

5d162fc..edddec5 389-ds-base-1.4.2 -> 389-ds-base-1.4.2
22a3b16..60818c0 389-ds-base-1.4.1 -> 389-ds-base-1.4.1

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/389ds/389-ds-base/issues/3813

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Metadata Update from @spichugi:
- Issue close_status updated to: wontfix (was: fixed)

a year ago

Login to comment on this ticket.

Metadata
Related Pull Requests