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

improved cli #15

Merged
merged 4 commits into from
Sep 4, 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
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,23 @@ To install your own code run `pip install -e .` in a terminal

## Features

Provide examples and explanations of how your project can be used. Include code snippets or screenshots if necessary.
Run `rlpm -h`

```
Usage: rlpm [-h] {quickstart,mapping,validate} ...

RareLink Phenopacket Mapper (RLPM) CLI tool.

positional arguments:
{quickstart,mapping,validate}
Available commands
quickstart Generate a notebook with sample code.
mapping Execute the mapping.
validate Validate phenopackets.

options:
-h, --help show this help message and exit
```

## Contributing

Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,4 @@ version = { attr = "rarelink_phenopacket_mapper.__version__" }
# The following would provide a command line executable called `sample`
# which executes the function `main` from this package when invoked.
[project.scripts] # Optional
quickstart = "rarelink_phenopacket_mapper.cli.quickstart:main"
mapping = "rarelink_phenopacket_mapper.cli.mapping:main"
validate = "rarelink_phenopacket_mapper.cli.validate:main"
rlpm = "rarelink_phenopacket_mapper.cli.main:main"
46 changes: 46 additions & 0 deletions src/rarelink_phenopacket_mapper/cli/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import argparse
from rarelink_phenopacket_mapper.cli.quickstart import main as quickstart_main
from rarelink_phenopacket_mapper.cli.mapping import main as mapping_main
from rarelink_phenopacket_mapper.cli.validate import main as validate_main


def main():
"""Main entry point for the rlpm CLI."""
parser = argparse.ArgumentParser(
prog='rlpm',
description='RareLink Phenopacket Mapper (RLPM) CLI tool.'
)

# Define subcommands
subparsers = parser.add_subparsers(dest='command', help='Available commands')

# Quickstart command
parser_quickstart = subparsers.add_parser('quickstart', help='Generate a notebook with sample code.')
parser_quickstart.add_argument('-p', '--path', type=str, help='Path the notebook should be written to')

# Mapping command
parser_mapping = subparsers.add_parser('mapping', help='Execute the mapping.')
parser_mapping.add_argument('-p', '--path', type=str, help='Path to RareLink formatted csv or excel file')
parser_mapping.add_argument('-o', '--output', type=str, help='Path to write Phenopackets to')
parser_mapping.add_argument('-v', '--validate', action='store_true',
help='Validate phenopackets using phenopacket-tools after creation')

# Validate command
parser_validate = subparsers.add_parser('validate', help='Validate phenopackets.')
parser_validate.add_argument('-p', '--path', type=str, help='Path to Phenopackets')

args = parser.parse_args()

# Route the command to the appropriate function
if args.command == 'quickstart':
quickstart_main(args)
elif args.command == 'mapping':
mapping_main(args)
elif args.command == 'validate':
validate_main(args)
else:
parser.print_help()


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion src/rarelink_phenopacket_mapper/cli/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from rarelink_phenopacket_mapper.cli.validate import validate


def main():
def main(args):
"""This method launches the mapping command"""
arg_parser = argparse.ArgumentParser(
prog='mapping',
Expand Down
2 changes: 1 addition & 1 deletion src/rarelink_phenopacket_mapper/cli/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path


def main():
def main(args):
"""This method launches the quickstart command"""
arg_parser = argparse.ArgumentParser(
prog='quickstart',
Expand Down
2 changes: 1 addition & 1 deletion src/rarelink_phenopacket_mapper/cli/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path


def main():
def main(args):
"""This method launches the validate command"""
arg_parser = argparse.ArgumentParser(
prog='validate',
Expand Down
Loading