GELOG / adam-ibs

Ports the IBS/MDS/IBD functionality of Plink to Spark / ADAM
Apache License 2.0
3 stars 6 forks source link

Command-line (CLI) option parser for Scala #23

Closed davidonlaptop closed 9 years ago

davidonlaptop commented 9 years ago

Description

All these plink features uses a different command line options, and some of these options can be combined or not (e.g. --cluster can be called alone are with multiple options). Each of these options can have 0, 1 or more parameters (e.g. --mcc A B).

I think the best way to think about this is with a tree-like structure. For each invocation of the program there is one main use case (e.g. clustering). Then each use case require mandatory options and offer optional options. The optional options can have a default value. Some options are shared by many use cases.

So with plink, it is not very clear which options are applicable to a use case. To improve this, we need to find a flexible, easy-to-use, and light-weight option for scala.

I'm a big fan of the git software approach:

$ git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty Git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG

'git help -a' and 'git help -g' lists available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.

$ git branch --help
(shows help on the git branch command)

Analysis

Add a comment to this issue with:

Add a comment to this issue describing the "tree" of available commands for the scope of the features implemented in MGL804.

Implementation

This need to be implemented in all features produced during MGL804.

francois-boyer commented 9 years ago

Available CLI parsers libraries:

Scopt (https://github.com/scopt/scopt, http://eed3si9n.com/scopt3) - Advantages:

scallop (https://github.com/scallop/scallop) - Advantages:

Manual

Argot (http://software.clapper.org/argot/) - Advantages:

Examples:

Manual:

ghost commented 9 years ago

@francois-boyer est-ce que tu as pu trouvé des inconvénients à utiliser l'une ou l'autre de ces librairies? pour connaître les limites de leurs utilisations. Ce que j'ai pu trouvé, c'est un article de l'auteur de Scallop, qui a utilisé Scopt, Argot et les autres CLI parsers d'Apache et qu'il les a trouvé limité dans leurs fonctionnalités: voir l'article suivant: http://blog.rogach.org/2012/04/better-cli-option-parsing-in-scala.html

francois-boyer commented 9 years ago

Merci pour l'article; ça m'aura permis de terminer la liste des avantages pour Scallop et de trouver un wiki.

Je dois avouer avoir beaucoup de difficulté à lister les désavantages de chacun des outils disponibles. Le truc est qu'il n'y a pas vraiment quelqu'un de neutre qui semble avoir comparé les trois outils les uns aux autres.

Dans l'article que tu proposes, par exemple, c'est l'auteur lui-même qui dit que son outil est mieux que les autres. Je veux bien le croire, mais ce n'est pas très neutre comme opinion.

Ceci dit, je crois qu'on pourrait essayer Scallop et voir s'il répond à nos besoins.

Serais-ce possible de me fournir la liste des options pour chacune des fonctionnalités accessibles aux utilisateurs. Je pourrai alors créer le nécessaire pour recevoir & valider les options de notre programme.

Merci.

ghost commented 9 years ago

Je suis d'accord avec toi. L'article présenté a été écrite par l'auteur de Scallop et trouves des inconvénients à l'utilisation de Scopt et d'Argot. Cependant, je n'ai pas trouvé d'autres articles qui comparait l'ensemble des CLI parsers disponible. La liste des options est disponible

iki-v commented 9 years ago

On met ce point sur l'ordre de jour de notre prochaine rencontre. L'objectif serait donc de se positionner sur le choix de la solution. Je propose à tout le monde de voir les différentes options pour la discussion de mercredi.