Skip to content

Commit

Permalink
add export-stix cli file-name arg
Browse files Browse the repository at this point in the history
  • Loading branch information
infosecB committed Nov 24, 2024
1 parent 8b5ca77 commit b12fc10
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/pyloobins/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,24 @@ def get(name: str, path: str = "") -> None:
help="Enter the path where you would like to create the template YAML file.",
default=".",
)
def export_stix(path: str = ".") -> None:
@click.option(
"--file-name",
type=str,
required=False,
help="Enter the path where you would like to create the template YAML file.",
default="loobins_stix.json",
)
def export_stix(file_name: str, path: str) -> None:
"""Export the LOOBins STIX bundle file."""
all_loobins = get_loobins()
stix_bundle = LOOBinsGroup(all_loobins)
with open(f"{path}/loobins_stix.json", mode="w+", encoding="utf-8") as f:
path = path if path and os.path.exists(path) else "./"
if not os.path.exists(path):
click.echo(
f"The specified path did not exist. "
f"Creating the {file_name}.yml file in the current directory."
)
with open(f"{path}/{file_name}", mode="w+", encoding="utf-8") as f:
f.write(stix_bundle.to_stix_bundle().serialize(pretty=True))


Expand Down

0 comments on commit b12fc10

Please sign in to comment.