All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mail: improve bash completion
@ 2016-11-28 18:14 Greg Kurz
  0 siblings, 0 replies; only message in thread
From: Greg Kurz @ 2016-11-28 18:14 UTC (permalink / raw)
  To: stgit-users; +Cc: Catalin Marinas

This adds completion of the --to, --cc and --bcc options based on the
content of the [mail "alias"] section of GIT configuration files.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 stgit/argparse.py      |    1 +
 stgit/commands/mail.py |    6 +++---
 stgit/completion.py    |    2 ++
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/stgit/argparse.py b/stgit/argparse.py
index 43c6cf9bbbb3..86f4a1095d10 100644
--- a/stgit/argparse.py
+++ b/stgit/argparse.py
@@ -286,6 +286,7 @@ known_files = Compgen(['$(_known_files)'])
 repo = Compgen(actions = ['directory'])
 dir = Compgen(actions = ['directory'])
 files = Compgen(actions = ['file'])
+mail_aliases = Compgen(['$(_mail_aliases)'])
 def strings(*ss): return Compgen(ss)
 class patch_range(CompgenBase):
     def __init__(self, *endpoints):
diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index ff9f2e11ca36..2dc3dba6680d 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -102,11 +102,11 @@ args = [argparse.patch_range(argparse.applied_patches,
 options = [
     opt('-a', '--all', action = 'store_true',
         short = 'E-mail all the applied patches'),
-    opt('--to', action = 'append',
+    opt('--to', action = 'append', args = [argparse.mail_aliases],
         short = 'Add TO to the To: list'),
-    opt('--cc', action = 'append',
+    opt('--cc', action = 'append', args = [argparse.mail_aliases],
         short = 'Add CC to the Cc: list'),
-    opt('--bcc', action = 'append',
+    opt('--bcc', action = 'append', args = [argparse.mail_aliases],
         short = 'Add BCC to the Bcc: list'),
     opt('--auto', action = 'store_true',
         short = 'Automatically cc the patch signers'),
diff --git a/stgit/completion.py b/stgit/completion.py
index 38f06705b76a..010fc4fbee0c 100644
--- a/stgit/completion.py
+++ b/stgit/completion.py
@@ -58,6 +58,8 @@ def util():
              'esac'),
          fun('_stg_branches',
              'local g=$(_gitdir)', 'test "$g" && (cd $g/patches/ && echo *)'),
+         fun('_mail_aliases',
+             'git config --name-only --get-regexp "^mail\.alias\." | cut -d. -f 3'),
          ref_list_fun('_all_branches', 'refs/heads'),
          ref_list_fun('_tags', 'refs/tags'),
          ref_list_fun('_remotes', 'refs/remotes')]

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-11-28 18:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-28 18:14 [PATCH] mail: improve bash completion Greg Kurz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.