control: tag -1 -patch

Hello,

On Sat 09 Nov 2019 at 07:10PM -05, Daniel Kahn Gillmor wrote:

> This is modeled after the use of argcomplete in diffoscope, and it
> should be possible to use it for any other pythonic mailscript that
> uses argparse.

Very cool!

> --- a/debian/rules
> +++ b/debian/rules
> @@ -1,4 +1,10 @@
>  #!/usr/bin/make -f
>
>  %:
> -     dh $@ --with elpa
> +     dh $@ --with elpa --with bash-completion
> +
> +debian/email-print-mime-structure.bash-completion:
> +     register-python-argcomplete3 email-print-mime-structure > $@
> +
> +override_dh_auto_build: debian/email-print-mime-structure.bash-completion
> +     dh_auto_build

Hmm, is this really Debian-specific, or could the call to
register-python-argcomplete3 go into the Makefile?

That would allow d/rules to remain very short, which is probably more
desirable.

> diff --git a/email-print-mime-structure b/email-print-mime-structure
> index 644efb1..eebd5e0 100755
> --- a/email-print-mime-structure
> +++ b/email-print-mime-structure
> @@ -122,6 +129,15 @@ def main() -> None:
>                                             epilog="Example: 
> email-print-mime-structure <message.eml")
>      parser.add_argument('--pgpkey', metavar='KEYFILE', action='append',
>                          help='OpenPGP Transferable Secret Key for 
> decrypting')
> +
> +    if argcomplete:
> +        argcomplete.autocomplete(parser)
> +    elif '_ARGCOMPLETE' in os.environ:
> +        logging.error('Argument completion requested but the "argcomplete" '
> +                      'module is not installed. '
> +                      'Maybe you want to "apt install python3-argcomplete"')
> +        sys.exit(1)

I'm not familiar with argparse -- can you explain the hard exit here?
I am guessing that _ARGCOMPLETE gets set when the user's shell invokes
email-print-mime-structure solely to obtain completion information?

-- 
Sean Whitton

Attachment: signature.asc
Description: PGP signature

Reply via email to