Skip to content

Commit

Permalink
Remove write cli option
Browse files Browse the repository at this point in the history
  • Loading branch information
remisalmon committed Jul 24, 2024
1 parent d1b922d commit f78206a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
15 changes: 2 additions & 13 deletions lkml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def parse_args(args: Sequence) -> argparse.Namespace:
)
)
parser.add_argument(
"file", type=argparse.FileType("r+"), help="path to the LookML file to parse"
"file", type=argparse.FileType("r"), help="path to the LookML file to parse"
)
parser.add_argument(
"-v",
Expand All @@ -109,13 +109,6 @@ def parse_args(args: Sequence) -> argparse.Namespace:
default=False,
help="return a LookML string",
)
group.add_argument(
"-w",
"--write",
action="store_true",
default=False,
help="parse and write back to file",
)

return parser.parse_args(args)

Expand All @@ -140,11 +133,7 @@ def cli():
try:
result: dict = load(args.file)

if args.write:
args.file.seek(0)
dump(result, args.file)
args.file.truncate()
elif args.lookml:
if args.lookml:
lookml_string = dump(result)
print(lookml_string)
elif args.json:
Expand Down
8 changes: 3 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ def test_load_with_bad_argument_raises_type_error():
def test_parse_default_option(lookml_path):
args = lkml.parse_args([lookml_path])
assert args.json is True
assert args.lookml is args.write is False
assert args.lookml is False


def test_parse_options(lookml_path):
args = lkml.parse_args([lookml_path, "--json"])
assert args.json is True

args = lkml.parse_args([lookml_path, "--lookml"])
assert args.lookml is True
args = lkml.parse_args([lookml_path, "--write"])
assert args.write is True
args = lkml.parse_args([lookml_path, "-w"])
assert args.write is True

with pytest.raises(SystemExit):
args = lkml.parse_args([lookml_path, "--json", "--lookml"])

Expand Down

0 comments on commit f78206a

Please sign in to comment.