Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lowercase names #117

Merged
merged 6 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Changelog
=========

* Change handling of lowercase module names

v0.1.28 (2023-09-29)
------------------------------------------


* Make choices style parsable (#114)

v0.1.27 (2023-08-25)
Expand Down
5 changes: 3 additions & 2 deletions src/mdacli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
A command line interface (CLI) to the analysis modules of MDAnalysis.

The modules are all structured as part of a single mdacli wrapper, and invoked
with commands like `mda RMSD`. This command uses the class
:class:`MDAnalysis.analysis.rms.RMSD` for calculating the RMSD.
with commands like `mda RMSD` (The lowercase `mda rmsd` is also supported).
This command uses the class :class:`MDAnalysis.analysis.rms.RMSD` for
calculating the RMSD.
Documentation for each module can be found at the respective sections on the
`MDAnalysis Documentation`_, as well as
`mda command -h`.
Expand Down
5 changes: 1 addition & 4 deletions src/mdacli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ def cli(name,
# sub parser in complete detail.
setup_clients(ap, title=f"{name} Analysis Modules", members=modules)

# Be case insensitive for the subcommand
sys.argv[1] = sys.argv[1].lower()

args = ap.parse_args()

if args.debug:
Expand All @@ -120,7 +117,7 @@ def cli(name,

# Get the correct ArgumentParser instance from all subparsers
# `[0]` selects the first subparser where our analysises live in.
_key = analysis_callable.__name__.lower()
_key = analysis_callable.__name__
ap_sup = ap._subparsers._group_actions[0].choices[_key]
arg_grouped_dict = split_argparse_into_groups(ap_sup, args)

Expand Down
3 changes: 2 additions & 1 deletion src/mdacli/libcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ def create_cli(sub_parser, interface_name, parameters):
# creates the subparser
analysis_class_parser = sub_parser.add_parser(
interface_name,
aliases=[interface_name.lower()],
help=parameters["desc"],
description=f"{parameters['desc']}\n\n{parameters['desc_long']}",
formatter_class=argparse.RawDescriptionHelpFormatter,
Expand Down Expand Up @@ -766,7 +767,7 @@ def setup_clients(ap, title, members):
# to be writen
for member_name, parameters in analysis_interfaces.items():
create_cli(sub_parser=cli_subparser,
interface_name=member_name.lower(),
interface_name=member_name,
parameters=parameters)


Expand Down
7 changes: 7 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ def test_case_insensitive(args):
subprocess.check_call(['mda', args, "-h"])


@pytest.mark.parametrize('args', ("RMSF", "rmsf"))
def test_case_insensitive_with_flags(args):
"""Test for module name being case insensitive with additional flags."""
# Check if it still works if the module name is not the second argument
subprocess.check_call(['mda', '--debug', args, "-h"])


def test_running_analysis(tmpdir):
"""Test running a complete analysis."""
with tmpdir.as_cwd():
Expand Down
Loading