Skip to content

Add filesystem meta-commands and path completion - #1613

Open
dcavalcante wants to merge 4 commits into
dbcli:mainfrom
dcavalcante:add-filesystem-meta-commands
Open

dcavalcante wants to merge 4 commits into
dbcli:mainfrom
dcavalcante:add-filesystem-meta-commands

Conversation

@dcavalcante

Copy link
Copy Markdown

Summary

  • Add \cd and \ls filesystem commands.
  • Add path completion for \cd, \e, \i, \log-file, \ls, and \o.
  • Handle directory-only completion, paths containing spaces, and filesystem errors.

Validation

  • 103 focused tests passed.
  • 2,618 non-SSH tests passed.

DiegoDAF added a commit to DiegoDAF/pgcli.daf that referenced this pull request Aug 14, 2026
@j-bennet

Copy link
Copy Markdown
Contributor

Hi @dcavalcante , there are some conflicts to resolve.

@dcavalcante

Copy link
Copy Markdown
Author

Hi @dcavalcante , there are some conflicts to resolve.

Hey @j-bennet thanks for the heads up, updated!

DiegoDAF added a commit to DiegoDAF/pgcli.daf that referenced this pull request Oct 13, 2026
Comment thread pgcli/pgcompleter.py
# e.g. 'table' -> self.get_table_matches
matcher = self.suggestion_matchers[suggestion_type]
matches.extend(matcher(self, suggestion, word_before_cursor))
completion_text = document.text_before_cursor if suggestion_type is Path else word_before_cursor

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you have to specialcase Path here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path needs the full command text because filesystem arguments can contain spaces.

The normal matcher input comes from document.get_word_before_cursor(WORD=True), so for something like:

\i space directory/q

it only gives the matcher directory/q. For path completion, though, the actual argument is space directory/q.

Passing document.text_before_cursor for Path lets get_path_matches() call parse_special_command() and recover the complete path argument before handing it to PathCompleter.

I special-cased it here to keep the existing matcher contract unchanged for the other suggestion types. There is also a regression test for this case in test_path_completion_handles_spaces.

@dcavalcante
dcavalcante requested a review from j-bennet October 16, 2026 18:37

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants