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

Add --version, lowercase parameter descriptions #86

Merged
merged 2 commits into from
Aug 25, 2023
Merged
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
20 changes: 12 additions & 8 deletions adtl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import itertools
import copy
import re
import importlib.metadata
from collections import defaultdict, Counter
from datetime import datetime
from pathlib import Path
Expand All @@ -28,6 +29,8 @@
Rule = Union[str, StrDict]
Context = Optional[Dict[str, Union[bool, int, str, List[str]]]]

__version__ = importlib.metadata.version("adtl")


def get_value(row: StrDict, rule: Rule, ctx: Context = None) -> Any:
"""Gets value from row using rule
Expand Down Expand Up @@ -890,31 +893,32 @@ def save(self, output: Optional[str] = None):
def main(argv=None):
cmd = argparse.ArgumentParser(
prog="adtl",
description="Transforms data into CSV given a specification (+validation)",
description="Transforms and validates data into CSV given a specification",
)
cmd.add_argument(
"spec",
help="Specification file to use",
help="specification file to use",
)
cmd.add_argument("file", help="File to read in")
cmd.add_argument("file", help="file to read in")
cmd.add_argument(
"-o", "--output", help="Output file, if blank, writes to standard output"
"-o", "--output", help="output file, if blank, writes to standard output"
)
cmd.add_argument(
"--encoding", help="Encoding input file is in", default="utf-8-sig"
"--encoding", help="encoding input file is in", default="utf-8-sig"
)
cmd.add_argument(
"-q",
"--quiet",
help="Quiet mode - decrease verbosity, disable progress bar",
help="quiet mode - decrease verbosity, disable progress bar",
action="store_true",
)
cmd.add_argument("--save-report", help="Save report in JSON format")
cmd.add_argument("--save-report", help="save report in JSON format")
cmd.add_argument(
"--include-def",
action="append",
help="Include external definition (TOML or JSON)",
help="include external definition (TOML or JSON)",
)
cmd.add_argument("--version", action="version", version="%(prog)s " + __version__)
args = cmd.parse_args(argv)
include_defs = args.include_def or []
spec = Parser(args.spec, include_defs=include_defs, quiet=args.quiet)
Expand Down