def __init__(self):
     self.package = datastruct.pacfile()
     self.target = ""
     self.start_id = 0
     self.deletes = []
     self.appends = []
     if os.path.isfile(environ_name):
         self.loadEnviron()
 def __init__(self):
     self.package = datastruct.pacfile()
     self.target = ""
     self.start_id = 0
     self.deletes = []
     self.appends = []
     if os.path.isfile(environ_name):
         self.loadEnviron()
def cliUI(cmdline):
    sekai = fileadding_utils.staging()
    docompress = not cmdline.no_compress
    dryrun = cmdline.dry_run
    # staging operations
    if cmdline.stage:
        if cmdline.add:
            if os.path.isfile(cmdline.file):
                if os.path.isdir(cmdline.base_dir):
                    relpath = os.path.relpath(cmdline.file, cmdline.base_dir)
                    newbie = sekai.addfile(relpath, cmdline.file, compression=docompress)
                    if newbie:
                        print("Added new file with name: " + datastruct.adjustSeparatorForPac(relpath))
                    else:
                        print("File " + datastruct.adjustSeparatorForPac(relpath) + " will be replaced")
                else:
                    print("directory \"" + cmdline.add + "\" si not valid")
            elif os.path.isdir(cmdline.file):
                sekai.addDirectory(cmdline.file, compression=docompress, verbose=True, wholedir=True)
            else:
                print("file \"" + cmdline.file + "\" not found")
            sekai.saveEnviron()
        elif cmdline.merge:
            if os.path.isdir(cmdline.file):
                sekai.addDirectory(cmdline.file, compression=docompress, verbose=True, wholedir=False)
            else:
                print("directory \"" + cmdline.add + "\" si not valid")
            sekai.saveEnviron()
        elif cmdline.undo:
            undid = sekai.undoFile(cmdline.file)
            if not undid:
                print("Warning: command had no effect (typo in filename?)")
            sekai.saveEnviron()
        elif cmdline.remove:
            removed = sekai.removeFile(cmdline.file)
            if not removed:
                print("Warning: command had no effect (typo in filename?)")
            sekai.saveEnviron()
        elif cmdline.commit:
            sekai.commit()
            print("Commit completed")
            sekai.saveEnviron()
        elif cmdline.write:
            sekai.writeout(cmdline.file, dry_run=dryrun, debuggy=cmdline.debug)
            if not dryrun:
                sekai.clearEnviron()
        elif cmdline.peek:
            nonStaging(sekai.package, cmdline, sekai.target)
        elif cmdline.list:
            sekai.listInfo()
        elif cmdline.list_harder:
            sekai.listDetailed()

        # other operations

        elif cmdline.file: # targeting (initialize staging)
            sekai.loadPackage(cmdline.file)
            print("Staging environment initialized with target pacfile: " + sekai.target)
            sekai.saveEnviron()

        else:
            sekai.start_id = cmdline.offset
            sekai.saveEnviron()

    # non-staging operations
    elif cmdline.file is not None:
        pac = datastruct.pacfile()
        with open(cmdline.file, "rb") as binfile:
            pac.loadFromFile(binfile)
        nonStaging(pac, cmdline, cmdline.file)

    else:
        if cmdline.version:
            print(info.getInfoMsg())
def cliUI(cmdline):
    sekai = fileadding_utils.staging()
    docompress = not cmdline.no_compress
    dryrun = cmdline.dry_run
    # staging operations
    if cmdline.stage:
        if cmdline.add:
            if os.path.isfile(cmdline.file):
                if os.path.isdir(cmdline.base_dir):
                    relpath = os.path.relpath(cmdline.file, cmdline.base_dir)
                    newbie = sekai.addfile(relpath, cmdline.file, compression=docompress)
                    if newbie:
                        print("Added new file with name: " + datastruct.adjustSeparatorForPac(relpath))
                    else:
                        print("File " + datastruct.adjustSeparatorForPac(relpath) + " will be replaced")
                else:
                    print('directory "' + cmdline.add + '" si not valid')
            elif os.path.isdir(cmdline.file):
                sekai.addDirectory(cmdline.file, compression=docompress, verbose=True, wholedir=True)
            else:
                print('file "' + cmdline.file + '" not found')
            sekai.saveEnviron()
        elif cmdline.merge:
            if os.path.isdir(cmdline.file):
                sekai.addDirectory(cmdline.file, compression=docompress, verbose=True, wholedir=False)
            else:
                print('directory "' + cmdline.add + '" si not valid')
            sekai.saveEnviron()
        elif cmdline.undo:
            undid = sekai.undoFile(cmdline.file)
            if not undid:
                print("Warning: command had no effect (typo in filename?)")
            sekai.saveEnviron()
        elif cmdline.remove:
            removed = sekai.removeFile(cmdline.file)
            if not removed:
                print("Warning: command had no effect (typo in filename?)")
            sekai.saveEnviron()
        elif cmdline.commit:
            sekai.commit()
            print("Commit completed")
            sekai.saveEnviron()
        elif cmdline.write:
            sekai.writeout(cmdline.file, dry_run=dryrun, debuggy=cmdline.debug)
            if not dryrun:
                sekai.clearEnviron()
        elif cmdline.peek:
            nonStaging(sekai.package, cmdline, sekai.target)
        elif cmdline.list:
            sekai.listInfo()
        elif cmdline.list_harder:
            sekai.listDetailed()

        # other operations

        elif cmdline.file:  # targeting (initialize staging)
            sekai.loadPackage(cmdline.file)
            print("Staging environment initialized with target pacfile: " + sekai.target)
            sekai.saveEnviron()

        else:
            sekai.start_id = cmdline.offset
            sekai.saveEnviron()

    # non-staging operations
    elif cmdline.file is not None:
        pac = datastruct.pacfile()
        with open(cmdline.file, "rb") as binfile:
            pac.loadFromFile(binfile)
        nonStaging(pac, cmdline, cmdline.file)

    else:
        if cmdline.version:
            print(info.getInfoMsg())