Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
#17: improve some messages on drives. Add upload and download operati…
Browse files Browse the repository at this point in the history
…ons.
  • Loading branch information
derrix060 committed Sep 19, 2018
1 parent 74dad08 commit 2eb40f0
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions onedrived/od_pref.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def print_all_drives():

def print_saved_drives():
click.echo(click.style('Drives that have been set up:', bold=True))
click.echo(f'Ref: {context.config_dir}/{context.DEFAULT_CONFIG_FILENAME}')
all_drive_ids = context.all_drives()
if len(all_drive_ids) > 0:
click.echo()
Expand All @@ -286,10 +287,11 @@ def print_saved_drives():
click.echo(' Account: %s (%s)' % (curr_account.account_email, curr_drive_config.account_id))
click.echo(' Local root: %s' % curr_drive_config.localroot_path)
click.echo(' Ignore file: %s' % curr_drive_config.ignorefile_path)
click.echo(' Upload operations: %s' % getattr(curr_drive_config, 'upload_operations', 'all'))
click.echo(' Download operations: %s' % getattr(curr_drive_config, 'download_operations', 'all'))
click.echo()
else:
click.echo(' No Drive has been setup with onedrived.\n')
return all_drive_ids
error(' No Drive has been setup with onedrived.\n')


def index_to_drive_table_row(index, drive_table):
Expand Down Expand Up @@ -440,9 +442,10 @@ def set_drive(drive_id=None, email=None, local_root=None, ignore_file=None):
@click.option('--drive-id', '-d', type=str, required=False, default=None,
help='ID of the Drive.')
@click.option('--yes', '-y', is_flag=True, default=False, required=False,
help='If set, quietly delete the Drive if existing without confirmation.')
help='If set, quietly delete the Drive without confirmation.')
def delete_drive(drive_id=None, yes=False):
all_drive_ids = print_saved_drives()
all_drive_ids = context.all_drives()
print_saved_drives()

if len(all_drive_ids) == 0:
return
Expand All @@ -452,10 +455,10 @@ def delete_drive(drive_id=None, yes=False):
error(translator['od_pref.del_drive.specify_drive_to_delete'])
return
index = click.prompt(translator['od_pref.del_drive.choose_index'], type=int)
if isinstance(index, int) and 0 <= index < len(all_drive_ids):
try:
drive_id = all_drive_ids[index]
else:
error('Error: "%s" is not a valid # number.' % str(index))
except KeyError:
error(f'Error: "{index}" is not a valid # number.')
return

if drive_id not in all_drive_ids:
Expand Down

0 comments on commit 2eb40f0

Please sign in to comment.