#!/usr/bin/python3

# austeilen: /usr/sbin/sophomorix-transfer -jj --scopy --from-user rrrr --to-user t20,t13,t02,t10,t16,t11,t17,t08,t26,t03,t14,t19,t06,t09,t22,t15,t24,t25,t21,t18,t01,t23,t04,t05,t12,t07 --from-path transfer/ausdruck-fertig.pdf --to-path transfer/rrrr_test/

# einsammeln:
# /usr/sbin/sophomorix-transfer -jj --move --keep-source-directory --from-user t20,t13,t02,t10,t16,t11,t17,t08,t26,t03,t14,t19,t06,t09,t22,t15,t24,t25,t21,t18,t01,t23,t04,t05,t12,t07, --to-user rrrr --from-path transfer/rrrr_test --to-path transfer/collected/20220401_15-30-04-test/ --to-path-addon fullinfo --no-target-directory::18230:: 

import sophomorix.smbclient
import argparse

parser = argparse.ArgumentParser(add_help = True,
                                 description = "SMB client for sophomorix to distrubute data from one user to multiple users")
parser.add_argument('--scopy',
                    action="store_true", # 'True' is the  default
                    default=True,
                    help='copy the files with sever-site copy method')
parser.add_argument('from_user',
                    type=str,
                    help='single user that has the source data')
parser.add_argument('--from-path',
                    type=str,
                    default='transfer',
                    help='subdir in users home that contains the source data')
parser.add_argument('to_users',
                    nargs='+', # at least one argument, maybe more
                    type=str,
                    help='(multiple) target data users ')
parser.add_argument('--to-path',
                    type=str,
                    default='transfer',
                    help='subdir in target users home')
arguments = parser.parse_args()
config = vars(arguments)

# the arguments are collected in the dictionary 'config'
print(config)

print("############################################################")

# select one value from the arguments object
print(f"1) The source user is: {arguments.from_user}")
print(f"1) The target users are: {arguments.to_users}")

# select one value from the config dictionary
print(f"2) The source user is: {config['from_user']}")
print(f"2) The target users are: {config['to_users']}")


sophomorix.smbclient.distribute(config)


#help(sophomorix.smbclient.distribute)


# example:
# 
# sophomorix-distribute --scopy chef maier mueller burger --from-path tele --to-path fon
