-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfiles.py
More file actions
33 lines (26 loc) · 906 Bytes
/
files.py
File metadata and controls
33 lines (26 loc) · 906 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import os
from pathlib import Path
import click
from _incydr_cli import logging_options
from _incydr_cli.core import IncydrCommand
from _incydr_cli.core import IncydrGroup
from _incydr_sdk.core.client import Client
path_option = click.option(
"--path",
help='The file path where to save the file. The path must include the file name (e.g. "/path/to/my_file.txt"). Defaults to a file named "downloaded_file" in the current directory.',
default=str(Path(os.getcwd()) / "downloaded_file"),
)
@click.group(cls=IncydrGroup)
@logging_options
def files():
"""Download files by SHA256 hash."""
@files.command(cls=IncydrCommand)
@click.argument("SHA256")
@path_option
@logging_options
def download(sha256: str, path: str):
"""
Download the file matching the given SHA256 hash to the target path.
"""
client = Client()
client.files.v1.download_file_by_sha256(sha256, path)