You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Appy (JIRA)" <ji...@apache.org> on 2016/11/01 03:16:59 UTC
[jira] [Commented] (HBASE-16982) Better integrate Apache CLI in
AbstractHBaseTool
[ https://issues.apache.org/jira/browse/HBASE-16982?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15624194#comment-15624194 ]
Appy commented on HBASE-16982:
------------------------------
DefaultParser (only non-deprecated parser) of Apache CLI supports both gnu and posix parsing. (https://commons.apache.org/proper/commons-cli/apidocs/org/apache/commons/cli/CommandLineParser.html)
Seeing both single-dash and double-dash options being used in our tools, i wanted to know if there was a well-defined distinction. [This stack-overflow answer|http://serverfault.com/questions/387935/whats-the-difference-betwen-the-single-dash-and-double-dash-flags-on-shell-comm] seems to highlight a good one. Will recommend reading it and following better option naming quality in future.
In Apache cli, short option name is prefixed with single-dash and long option name with double-dash. If short name doesn't make sense for an option, use null in its place. (See ExportSnapshot tool).
> Better integrate Apache CLI in AbstractHBaseTool
> ------------------------------------------------
>
> Key: HBASE-16982
> URL: https://issues.apache.org/jira/browse/HBASE-16982
> Project: HBase
> Issue Type: Improvement
> Reporter: Appy
> Assignee: Appy
> Attachments: HBASE-16982.master.001.patch
>
>
> Problem
> 1. Inconsistencies in our user facing tools.
> - options:
> start with single/double dash
> words separated by dash or underscore or just joined together
> someplace use '=' to separate value, other use space (ExportSnapshot vs HashTable)
> - Description
> Manually formatting options and their descriptions in printUsage()
> Inconsistant formatting, sometimes even weird.
> Incomplete. Sometimes people forget to add new option to description
> 2. Manual parsing of options (those huge if-else loops iterating over args)
> Solution
> Use Apache CLI
> - It has various validations for option names which'll fix first set of issues.
> - using AbstractHBaseTool's print usage function will ensure consistent formatting (although we loose the power to order the options)
> - If we enforce the method of defining options as in patch, it's highly unlikely to forget adding description.
> - CLI parses the options for us.
> Using Apache CLI when writing new tools is straight forward, but it's not easy when porting exiting tools since some option names are not valid as per CLI's validation.
> New method, processOldArgs(), will allow to port these tools in a backward compatible manner.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)