feature: Add max days argument #4

Merged
anihm136 merged 3 commits from feat/add_max_age into master 2021-10-13 09:57:22 +02:00
Showing only changes of commit 45059e3b0d - Show all commits
+6 -1
View File
@@ -13,6 +13,8 @@ URL_TRANSFERSH = 'https://transfer.sh'
@click.command() @click.command()
@click.argument('filename') @click.argument('filename')
def transfersh_cli(filename): def transfersh_cli(filename):
@click.option('-a', '--max-days', type=int, help='Maximum number of days to keep file')
def transfersh_cli(filename, max_days, max_downloads):
""" Program that uploads a file to Transfer.sh """ """ Program that uploads a file to Transfer.sh """
try: try:
# Open file # Open file
@@ -20,7 +22,10 @@ def transfersh_cli(filename):
click.echo('Uploading file') click.echo('Uploading file')
# Upload file # Upload file
conf_file = {filename: data} conf_file = {filename: data}
r = requests.post(URL_TRANSFERSH, files=conf_file) headers = {}
if max_days is not None:
headers['Max-Days'] = str(max_days)
r = requests.post(URL_TRANSFERSH, files=conf_file, headers=headers)
# Shows route to download # Shows route to download
download_url = r.text download_url = r.text
click.echo(f'Download from here: {download_url}') click.echo(f'Download from here: {download_url}')