I'm having issues calling functions from the command line with argparse. I just want it to execute one of the functions defined in the script.
import os
import shutil
import getpass
import argparse
user = getpass.getuser()
copyfolders = ['Favorites']
parser = argparse.ArgumentParser()
parser.add_argument('e', action='store')
parser.add_argument('i', action='store')
args = parser.parse_args()
def exp(args):
for folder in copyfolders:
c_path = os.path.join("C:", "/", "Users", user, folder)
l_path = os.path.join("L:", "/", "backup", folder)
shutil.copytree(c_path, l_path)
def imp(args):
for folder in copyfolders:
l_path = os.path.join("L:", "/", "backup", folder)
c_path = os.path.join("C:", "/", "Users", user, folder)
shutil.copytree(l_path, c_path)
When I try to call it with an argument I get:
error the follow arguments are required: i
No matter what argument is passed.