Bug#678055: dhelp: Porting dhelp to use OptionParser instead of CommandLine::Application
Package: dhelp
Version: 0.6.20
Severity: important
Tags: patch
Hi,
We have decided Wheezy will be released with Ruby 1.9.1 as the default
interpreter¹, leaving Ruby 1.8 as an option, and committing to remove
it by Wheezy+1.
This package, dhelp, depends on CommandLine::Application (in package
ruby-commandline, which supersedes libcommandline-ruby) to parse the
command line arguments. This module, however, is not compatible with
Ruby 1.9.1 — It not even dies correctly!²
While Cédric Boutillier has (preliminarly, at least) prepared a patch
making CommandLine::Application work again, I am of the opinion we
should drop it for Debian's new stable version⁴. It has not seen a new
release since 2005, and its functionality is provided by OptionParser,
which is part of Ruby's standard library.
I wrote a small patch to migrate dhelp to use OptionParser instead,
but have not really tested it — Anyway, the differences are quite
trivial, and they should be very easy to understand.
Please consider incorporating this patch into
dhelp. CommandLine::Application is currently RC-buggy, and I think its
removal will be soon be requested (that will raise this bug's severity
to "grave", as this package will no longer be usable).
Greetings,
¹ http://lists.debian.org/debian-devel-announce/2012/06/msg00001.html
² http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=676248
³ http://lists.debian.org/debian-ruby/2012/06/msg00052.html
⁴ http://lists.debian.org/debian-ruby/2012/06/msg00051.html
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.2.0-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages dhelp depends on:
ii doc-base 0.10.3
ii libcommandline-ruby1.8 0.7.10-13
ii libdata-page-perl 2.02-1
ii libdb-ruby1.8 0.6.5-7
ii libgettext-ruby1.8 2.1.0-2.1
ii libhtml-parser-perl 3.69-2
ii liblocale-gettext-perl 1.05-7+b1
ii libtemplate-perl 2.22-0.1+b2
ii liburi-perl 1.60-1
ii perl-modules 5.14.2-11
ii poppler-utils 0.18.4-2
ii pstotext 1.9-6
ii ruby-bdb [libdb-ruby1.8] 0.6.5-7
ii ruby-commandline [libcommandline-ruby1.8] 0.7.10-13
ii ruby1.8 1.8.7.358-4
ii swish++ 6.1.5-2.2
ii ucf 3.0025+nmu3
Versions of packages dhelp recommends:
ii chromium [www-browser] 18.0.1025.168~r134367-1
ii elinks [www-browser] 0.12~pre5-7
ii iceape [www-browser] 2.7.4-2
ii iceweasel [www-browser] 10.0.4esr-3
ii links2 [www-browser] 2.6-2
ii lynx-cur [www-browser] 2.8.8dev.12-2
ii midori [www-browser] 0.4.3-1
ii w3m [www-browser] 0.5.3-8
Versions of packages dhelp suggests:
ii apache2-mpm-prefork [httpd] 2.2.22-6
ii catdvi <none>
ii html2text 1.3.2a-15
ii info2www <none>
ii man2html <none>
ii w3m 0.5.3-8
-- no debconf information
>From 5d55b5dfee0c1747c4e121c9893c8c2b2bd9d380 Mon Sep 17 00:00:00 2001
From: Gunnar Wolf <gwolf@gwolf.org>
Date: Mon, 18 Jun 2012 16:06:26 -0500
Subject: [PATCH] Ported from CommandLine::Application to OptionParser
---
dhelp_parse.rb | 81 ++++++++++++++++++++++++++++++++++----------------------
1 file changed, 50 insertions(+), 31 deletions(-)
diff --git a/dhelp_parse.rb b/dhelp_parse.rb
index 3c71d32..55c3baf 100755
--- a/dhelp_parse.rb
+++ b/dhelp_parse.rb
@@ -1,4 +1,5 @@
#!/usr/bin/ruby1.8 -w
+# -*- coding: utf-8 -*-
=begin
Documentation generator for dhelp
@@ -28,7 +29,7 @@ require 'dhelp'
require 'dhelp/exporter/html'
include Dhelp
-require 'commandline'
+require 'optparse'
require 'find'
require 'yaml'
@@ -51,43 +52,59 @@ end
# dhelp_parse application class
-class DhelpParseApp < CommandLine::Application
+class DhelpParseApp
DHELP_CONF_FILE = "/etc/dhelp.conf"
DOC_DIR = '/usr/share/doc'
DOC_BASE_DHELP_DIR = '/var/lib/doc-base/dhelp'
DEFAULT_SEARCH_DIRS = [DOC_DIR, DOC_BASE_DHELP_DIR]
+ Version = "0.2.0"
+ Author = "Esteban Manchado Velázquez"
+ Copyright = "Copyright (c) 2005-2007, Esteban Manchado Velázquez"
+ Synopsis = "[-v] [-h] -a doc-base_file1 d-b_f2 ... | -d doc-base_file1 d-b_f2 ... | -i | -r"
+ ShortDescription = "Debian online help system parser"
+ LongDescription = "Dhelp parser to add/remove/index-incrementally/fully-reindex dhelp files"
+
+
def initialize
- version "0.2.0"
- author "Esteban Manchado Velázquez"
- copyright "Copyright (c) 2005-2007, Esteban Manchado Velázquez"
- synopsis "[-v] [-h] -a doc-base_file1 d-b_f2 ... | -d doc-base_file1 d-b_f2 ... | -i | -r"
- short_description "Debian online help system parser"
- long_description "Dhelp parser to add/remove/index-incrementally/fully-reindex dhelp files"
-
- option :help
- option :names => %w(-a), :arity => [0,-1],
- :opt_found => lambda {|opt, name, value| @action = :add;
- @doc_base_files = value },
- :opt_description => "add documents registered in the given doc-base file"
- option :names => %w(-d), :arity => [0,-1],
- :opt_found => lambda {|opt, name, value| @action = :delete;
- @doc_base_files = value },
- :opt_description => "remove documents registered in the given doc-base file"
- option :names => %w(-v), :arity => [0,0],
- :opt_found => lambda { @verbose = true },
- :opt_description => "verbose"
- option :names => %w(-i), :arity => [0,0],
- :opt_found => lambda { @action = :index },
- :opt_description => "perform deferred incremental indexing of pending registered docs"
- option :names => %w(-r), :arity => [0,0],
- :opt_found => lambda { @action = :reindex },
- :opt_description => "perform full re-indexing of all registered docs"
-
- expected_args [0,0]
-
- @action = nil
+ @action = nil
@verbose = false
+
+ optparse = OptionParser.new do |opts|
+ opts.banner = "%s - %s\n\nSYNOPSIS:\n\t%s\n\n" % [$0, LongDescription, Synopsis]
+
+ opts.on('-h', '--help', 'Display this screen') {
+ puts opts
+ exit 0
+ }
+
+ opts.on('--version') {
+ puts '%s version %s' % [$0, Version]
+ exit 0
+ }
+
+ opts.on('-a FILE', 'Add documents registered in the given doc-base file'
+ ) { |files|
+ @action = :add
+ @doc_base_files = files
+ }
+
+ opts.on('-d FILE', 'Remove documents registered in the given doc-base file'
+ ) { |files|
+ @action = :delete
+ @doc_base_files = files
+ }
+
+ opts.on('-v', 'Verbose') { @verbose = true }
+
+ opts.on('-i', 'Perform deferred incremental indexing of pending registered docs'
+ ) { @action = :index }
+
+ opts.on('-r', 'Perform full re-indexing of all registered docs'
+ ) { @action = :reindex }
+ end
+
+ optparse.parse!
end
def packaged_configured?
@@ -185,3 +202,5 @@ class DhelpParseApp < CommandLine::Application
puts "#{e.class}: #{e} (#{e.backtrace.join("\n")})"
end
end
+
+DhelpParseApp.new.main
--
1.7.10
Reply to: