mirror of
https://github.com/postgres/postgres.git
synced 2026-01-26 09:41:40 +03:00
psql: Add tab completion for pstdin and pstdout in \copy.
This commit adds tab completion support for the keywords "pstdin" and "pstdout" in the \copy command. "pstdin" is now suggested after FROM, and "pstdout" is suggested after TO, alongside filenames and other keywords. Author: Yugo Nagata <nagata@sraoss.co.jp> Reviewed-by: Srinath Reddy Sadipiralla <srinath2133@gmail.com> Reviewed-by: Kirill Reshke <reshkekirill@gmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Discussion: https://postgr.es/m/20251231183953.95132e171e43abd5e9b78084@sraoss.co.jp
This commit is contained in:
@@ -3357,13 +3357,22 @@ match_previous_words(int pattern_id,
|
||||
/* Complete COPY|\copy <sth> FROM|TO with filename or STDIN/STDOUT/PROGRAM */
|
||||
else if (Matches("COPY|\\copy", MatchAny, "FROM|TO"))
|
||||
{
|
||||
/* COPY requires quoted filename */
|
||||
bool force_quote = HeadMatches("COPY");
|
||||
|
||||
if (TailMatches("FROM"))
|
||||
COMPLETE_WITH_FILES_PLUS("", force_quote, "STDIN", "PROGRAM");
|
||||
if (HeadMatches("COPY"))
|
||||
{
|
||||
/* COPY requires quoted filename */
|
||||
if (TailMatches("FROM"))
|
||||
COMPLETE_WITH_FILES_PLUS("", true, "STDIN", "PROGRAM");
|
||||
else
|
||||
COMPLETE_WITH_FILES_PLUS("", true, "STDOUT", "PROGRAM");
|
||||
}
|
||||
else
|
||||
COMPLETE_WITH_FILES_PLUS("", force_quote, "STDOUT", "PROGRAM");
|
||||
{
|
||||
/* \copy supports pstdin and pstdout */
|
||||
if (TailMatches("FROM"))
|
||||
COMPLETE_WITH_FILES_PLUS("", false, "STDIN", "PSTDIN", "PROGRAM");
|
||||
else
|
||||
COMPLETE_WITH_FILES_PLUS("", false, "STDOUT", "PSTDOUT", "PROGRAM");
|
||||
}
|
||||
}
|
||||
|
||||
/* Complete COPY|\copy <sth> FROM|TO PROGRAM */
|
||||
|
||||
Reference in New Issue
Block a user