Skip to content

Commit

Permalink
Migrate CLI parsing to click library
Browse files Browse the repository at this point in the history
Complete overhaul of top-level parsing.  Delegation to subcommands using
click.group(). Structure of parsing within each of the subcommand is
retained, but some of the wrapping code for help functions and version
options is no longer needed.

Changes to CLI API:

- webdav/archive/mirror flags no longer specifiable as mutually
  exclusive group
- argument order in comment is changed to smt comment COMMENT [LABEL]

The first of these cannot be fixed without changes to click API (see
issue open-research#257 pallets/click#257). The second is
a little more annoying from a user perspective. Though it may be fixable
given current api. So far, though, I can't figure out how to pass
optional arguments before required. I wouldn't be surprised if it isn't
possible either.

A few associated changes:

* Currently using click to print in simplest way possible: click echo,
* and for
  error-like messages specifying err=True to print to standard error.
* Because of change, help files look and print slightly (or in some
  cases majorly) differently

Changes to commands.py API:

* Breaking changes to the arguments expected by all functions
  implementing smt subcommands. This is unavoidable with click.

Remaining issues :

* many test failures due to API changes -- around 67
  (filtering calls to parse_arguments from grep -E 'commands\..+(\(|\,)'
  test_commands.py) lines of the test suite for commands.py will need to
  be rewritten
* test rewrite should be straightforward change from tuples to named args
* migration to click doesn't intend to change downstream behavior so
  passing tests can serve as a check on rewrite
* docs not updated to modified look of help pages
  • Loading branch information
ashander committed May 8, 2015
1 parent 924a2d6 commit 7d8e9d9
Show file tree
Hide file tree
Showing 3 changed files with 474 additions and 448 deletions.
34 changes: 0 additions & 34 deletions bin/smt

This file was deleted.

8 changes: 6 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ def get_tip_revision(self, path=os.getcwd()):
'web/templates/*.html',
'publishing/latex/sumatra.sty',
'formatting/latex_template.tex', 'external_scripts/script_introspect.R']},
scripts = ['bin/smt', 'bin/smtweb', 'bin/smt-complete.sh'],
scripts = ['bin/smtweb', 'bin/smt-complete.sh'],
entry_points="""
[console_scripts]
smt = sumatra.commands:cli
""",
author = "Sumatra authors and contributors",
author_email = "[email protected]",
description = "A tool for automated tracking of computation-based scientific projects",
Expand All @@ -59,7 +63,7 @@ def get_tip_revision(self, path=os.getcwd()):
'Topic :: Scientific/Engineering'],
cmdclass = {'sdist': sdist_hg},
install_requires = ['Django>=1.4, <=1.6.11', 'django-tagging', 'httplib2',
'docutils', 'jinja2', 'parameters'],
'docutils', 'jinja2', 'parameters', 'Click'],
extras_require = {'svn': 'pysvn',
'hg': 'mercurial',
'git': 'GitPython',
Expand Down
Loading

0 comments on commit 7d8e9d9

Please sign in to comment.