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 -q/--quiet feature #29

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
15 changes: 11 additions & 4 deletions protonup/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ def installed_versions() -> list:
return versions_found


def get_proton(version=None, yes=True, dl_only=False, output=None) -> None:
def get_proton(version=None, yes=True, dl_only=False, output=None, quiet=True) -> None:
show = False
if yes or quiet:
show = True
"""Download and (optionally) install Proton"""
installdir = install_directory()
data = fetch_data(tag=version)
Expand Down Expand Up @@ -117,12 +120,16 @@ def get_proton(version=None, yes=True, dl_only=False, output=None) -> None:
return

# Confirmation
if not yes:
if not yes and not quiet:
print(f"Ready to download Proton-{data['version']}",
f"\nSize : {readable_size(data['size'])}",
f"\nPublished : {data['date']}")
if input("Continue? (Y/n): ") not in ['y', 'Y', '']:
return
elif yes:
print(f"Ready to download Proton-{data['version']}",
f"\nSize : {readable_size(data['size'])}",
f"\nPublished : {data['date']}")

# Prepare Destination
destination = output if output else (os.getcwd() if dl_only else TEMP_DIR)
Expand All @@ -132,8 +139,8 @@ def get_proton(version=None, yes=True, dl_only=False, output=None) -> None:
destination = os.path.expanduser(destination)

# Download
if not download(url=data['download'], destination=destination, show_progress=not yes):
if not yes:
if not download(url=data['download'], destination=destination, show_progress=not show):
if not show:
print("[ERROR] Download failed")
return

Expand Down
3 changes: 2 additions & 1 deletion protonup/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def parse_arguments():
help='set download directory')
parser.add_argument('-d', '--dir', type=str, default=None, help='set installation directory')
parser.add_argument('-y', '--yes', action='store_true', help='disable prompts and logs')
parser.add_argument('-q', '--quiet', action='store_true', help='disable prompts but show logs')
parser.add_argument('--download', action='store_true', help='download only')
parser.add_argument('--releases', action='store_true', help='list available versions')
return parser.parse_args()
Expand All @@ -31,7 +32,7 @@ def main():

if args.tag or not (args.remove or args.list or args.dir or args.releases):
get_proton(version=args.tag, yes=args.yes, dl_only=args.download,
output=args.output)
output=args.output, quiet=args.quiet)
if args.remove:
if args.yes or input(f"Confirm remove {args.remove}? (Y/n): ") not in ['y', 'Y', '']:
return
Expand Down