Skip to content

Commit

Permalink
+ implement option to show full path while recursive listing
Browse files Browse the repository at this point in the history
  • Loading branch information
elgarfo committed Aug 27, 2018
1 parent 1ad2ab3 commit 83feaa2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
22 changes: 14 additions & 8 deletions onedrivecmd/utils/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def do_direct(client, args):
return client


def do_list(client, args):
def do_list(client, args, lFolders = None):
"""OneDriveClient, [str] -> OneDriveClient
List the content of a remote folder,
Expand All @@ -309,31 +309,37 @@ def do_list(client, args):
the programme can just...crash. But who cares? I do not own Microsoft.
"""

is_recursive = args.recursive
show_fullpath = args.fullpath

# recursive call
if isinstance(args, list):
folder_list = args
is_recursive = True
if isinstance(lFolders, list):
folder_list = lFolders
else: # first call
folder_list = args.rest
is_recursive = args.recursive

# Nothing provided. Instead of giving a error, list the root folder
if folder_list == []:
folder_list.append('/')

for path in folder_list:
# get the folder entry point
folder = get_remote_item(client, path = path_to_remote_path(path))
curPath = path_to_remote_path(path)
folder = get_remote_item(client, path = curPath)

for i in folder:
name = 'od:/' + i.name
if show_fullpath:
name = 'od:' + curPath + '/' + i.name
else:
name = 'od:/' + i.name

if i.folder:
# make a little difference so the user can notice
name += '/'

# handle recursive
if is_recursive:
do_list(client, [get_remote_path_by_item(i) + '/'])
do_list(client, args, [get_remote_path_by_item(i) + '/'])

# format as megacmd

Expand Down
6 changes: 6 additions & 0 deletions onedrivecmd/utils/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ def parse_args():
choices = ['DEBUG', 'INFO', 'WARNING', 'ERROR'],
default = 'WARNING',
help = 'Set the logging level')

# Show full path instead of short one while listing
parser.add_argument('-fullpath',
action = 'store_true',
default = False,
help = 'Show full path instead of short one while listing')

## Script actions
# Set mutually exclusive actions
Expand Down

0 comments on commit 83feaa2

Please sign in to comment.