Hi, all !
Pabs, Thanks for suggestions :)
I made the changes as you mentioned, please find an attached patches.

On Sun, Jun 12, 2016 at 1:31 PM, Paul Wise <p...@debian.org> wrote:

> On Sun, 2016-06-12 at 11:50 +0530, Satyam Zode wrote:
>
> > Tags: patch
>
> That only works in mails to sub...@bugs.debian.org, for mails to the
> bug report address, you want this instead (-1 means the current bug):
>
> Control: tags -1 + patch
>
> > I have updated the patch as per suggestions please review it.
>
> Review below...
>
> >  override_dh_clean:
> > +     debian/diffoscope.bash-completion
>
> This causes the package to fail to build. I think override_dh_clean
> should be removed and both the bash completion script and
> debian/diffoscope.1 added to debian/clean. Moving the existing things
> to the debian/clean file should be done in a separate commit.
>
> >       dh_python3 --recommends=python-debian --recommends=rpm-python
> --recommends=tlsh --recommends=guestfs
>
> This line needs to add --recommends=argcomplete
>
> > +override_dh_auto_build:
> > +     register-python-argcomplete diffoscope >
> debian/diffoscope.bash-completion
>
> This disables the upstream build system, you should call dh_auto_build
> after calling register-python-argcomplete, I think this is a better way
> to do it than what is there now:
>
> override_dh_auto_build:
> debian/diffoscope.bash-completion debian/diffoscope.1
>
> debian/diffoscope.bash-completion:
>         register-python-argcomplete diffoscope > $@
>
I made above changes and here is build log : http://paste.debian.net/740041/
I am not sure if anything else is needed or not in debian/* files.


>
> You also need to add generated files to .gitignore so they don't get
> accidentally committed to the repository.
>
> > +* ``python-argcomplete`` is used for argument completion.
> > +  Available on Debian and Fedora as
> > +  ``python-argcomplete``.
> > +  ``python-argcomplete`` is also available on `PyPI ` as
> > +  ``argcomplete``.
>
> I think I would write that like this:
>
> * ``argcomplete`` is used for argument completion.
>   Available on Debian as ``python3-argcomplete``.
>   Available on Fedora as ``python-argcomplete``.
>   Available on `PyPI <https://pypi.python.org/pypi/argcomplete/>`_.
>
>
I have made these changes too.


> > -                        default=Config.general.max_report_size)
> >
> +                        
> default=Config.general.max_report_size).completer=RangeCompleter(0,
> > +                        Config.general.max_report_size, 200000)
>
> I think this prevents people from completing values above the
> default max_report_size? Same for the other RangeCompleters.
>
> Interestingly, in the range completers, 1000000 appears to sort before
> 800000, so it is doing string sorting not numeric sorting.
>

I have removed this temporarily! we already had discussion regarding this
on IRC.
Looking forward to your response!


Thanks!
Satyam Zode
From 43f3ed25ab3138cf353c3a34438cc7b8c8418e83 Mon Sep 17 00:00:00 2001
From: Satyam Zode <satyamz...@gmail.com>
Date: Sat, 18 Jun 2016 22:12:58 +0530
Subject: [PATCH 4/4] Added new rules for bash-completion script

---
 debian/rules | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/debian/rules b/debian/rules
index b15a73b..a4bdf79 100755
--- a/debian/rules
+++ b/debian/rules
@@ -8,10 +8,10 @@ ifneq ($(VERSION_dch),$(VERSION_py))
 endif
 
 %:
-	dh $@ --with python3 --buildsystem=pybuild
+	dh $@ --with python3 --with bash-completion --buildsystem=pybuild
 
 override_dh_python3:
-	dh_python3 --recommends=python-debian --recommends=rpm-python --recommends=tlsh --recommends=guestfs
+	dh_python3 --recommends=python-debian --recommends=rpm-python --recommends=tlsh --recommends=guestfs --recommends=argcomplete
 
 override_dh_gencontrol:
 	TOOLS="$$(bin/diffoscope --list-tools=debian | tail -n 1 | \
@@ -23,13 +23,16 @@ override_dh_gencontrol:
 debian/diffoscope.1: debian/diffoscope.1.rst
 	rst2man $< $@
 
+debian/diffoscope.bash-completion:
+	register-python-argcomplete diffoscope > $@
+
+dh_auto_build:
+	debian/diffoscope.bash-completion
+	debian/diffoscope.1
+
 override_dh_installman: debian/diffoscope.1
 	dh_installman -O--buildsystem=pybuild
 
-override_dh_clean:
-	rm -f debian/diffoscope.1
-	dh_clean -O--buildsystem=pybuild
-
 diffoscope/presenters/icon.py: favicon.png
 	(echo '# Generated from favicon.png'; \
 	 echo 'FAVICON_BASE64 = """'; \
-- 
2.1.4

From d7192fb92a4fca051bee2b13548878923c34995e Mon Sep 17 00:00:00 2001
From: Satyam Zode <satyamz...@gmail.com>
Date: Sat, 18 Jun 2016 22:05:19 +0530
Subject: [PATCH 3/4] Added debian/clean file

---
 debian/clean | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 debian/clean

diff --git a/debian/clean b/debian/clean
new file mode 100644
index 0000000..6e1cd10
--- /dev/null
+++ b/debian/clean
@@ -0,0 +1,3 @@
+rm -f debian/diffoscope.1
+dh_clean -O--buildsystem=pybuild
+debian/diffoscope.bash-completion
-- 
2.1.4

From 160eb9e209b5ed99fab7f19dff92f3dbd707e311 Mon Sep 17 00:00:00 2001
From: Satyam Zode <satyamz...@gmail.com>
Date: Sat, 18 Jun 2016 21:55:28 +0530
Subject: [PATCH 2/4] Added dependencies for argument completion

---
 debian/control | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/debian/control b/debian/control
index 19619d7..b24fbef 100644
--- a/debian/control
+++ b/debian/control
@@ -7,9 +7,11 @@ Uploaders:
  Mattia Rizzolo <mat...@debian.org>,
  Reiner Herrmann <rei...@reiner-h.de>,
 Build-Depends:
+ bash-completion,
  binutils-multiarch,
  debhelper (>= 9),
  dh-python,
+ python-argcomplete,
  python3-all,
  python3-debian,
  python3-docutils,
-- 
2.1.4

From 9a020124c6955c666bdfd8c385f43d80f93c6175 Mon Sep 17 00:00:00 2001
From: Satyam Zode <satyamz...@gmail.com>
Date: Sat, 18 Jun 2016 21:39:45 +0530
Subject: [PATCH 1/4] Added support for argument completion *
 diffoscope/__main__.py   : argument completion support using python
 argcomplete * diffoscope/README.rst: Updated documentation for
 python-argcomplete * diffoscope/bin/diffoscope: Added env var
 PYTHON_ARGCOMPLETE_OK

---
 README.rst             |  4 ++++
 bin/diffoscope         |  1 +
 diffoscope/__main__.py | 11 +++++++++++
 3 files changed, 16 insertions(+)

diff --git a/README.rst b/README.rst
index 5288e52..a2291d6 100644
--- a/README.rst
+++ b/README.rst
@@ -59,6 +59,10 @@ Optionally, the following modules will enhance it:
   ``python-magic``. It is built from `file
   <http://www.darwinsys.com/file/>`_.
   Available on Debian and Fedora as ``python3-magic``.
+*  ``argcomplete`` is used for argument completion.
+  Available on Debian as ``python3-argcomplete``.
+  Available on Fedora as ``python-argcomplete``.
+  Available on `PyPI <https://pypi.python.org/pypi/argcomplete/>`
 
 The various comparators rely on external commands being available. To
 get a list of them, please run::
diff --git a/bin/diffoscope b/bin/diffoscope
index 2393807..2422b70 100755
--- a/bin/diffoscope
+++ b/bin/diffoscope
@@ -1,4 +1,5 @@
 #!/usr/bin/env python3
+# PYTHON_ARGCOMPLETE_OK
 # -*- coding: utf-8 -*-
 #
 # diffoscope: in-depth comparison of files, archives, and directories
diff --git a/diffoscope/__main__.py b/diffoscope/__main__.py
index ac7913c..9e7e776 100644
--- a/diffoscope/__main__.py
+++ b/diffoscope/__main__.py
@@ -1,4 +1,5 @@
 #!/usr/bin/env python3
+# PYTHON_ARGCOMPLETE_OK
 # -*- coding: utf-8 -*-
 #
 # diffoscope: in-depth comparison of files, archives, and directories
@@ -30,6 +31,10 @@ try:
     import tlsh
 except ImportError:
     tlsh = None
+try:
+    import argcomplete
+except ImportError:
+    argcomplete = None
 from diffoscope import logger, VERSION, set_locale, clean_all_temp_files
 import diffoscope.comparators
 from diffoscope.config import Config
@@ -89,6 +94,12 @@ def create_parser():
     parser.add_argument('file2', help='second file to compare')
     if not tlsh:
         parser.epilog = 'File renaming detection based on fuzzy-matching is currently disabled. It can be enabled by installing the “tlsh” module available at https://github.com/trendmicro/tlsh'
+    if argcomplete:
+        argcomplete.autocomplete(parser)
+    elif '_ARGCOMPLETE' not in os.environ:
+        print('ERROR: Argument completion requested but Python argcomplete module not installed', file=sys.stderr)
+        sys.exit(1)
+
     return parser
 
 
-- 
2.1.4

Reply via email to