zen0wu / topcoder-greed

greedy editor for topcoder arena
Apache License 2.0
229 stars 45 forks source link

Backup configuration #88

Closed vexorian closed 10 years ago

vexorian commented 10 years ago

I think it is great greed saves backups of files it overrides. But I would like to be able to customize the file name. It would be specially useful to be able to use .filename.bak.0, so that the file is hidden. Let's agree on config syntax.

greed {

backup {
   # Replaces the file name format, backup is saved in the same folder as output file.
    fileName = "${GeneratedFileName}.bak.${BackupNumber}"

    # Sets the backup file limit
    fileCountLimit =  3
}

}

This reuses the GeneratedFileName that is used for after gen hooks.

It is possible to use folder structures. But backup folder structure needs to be a subfolder of the place where the file is getting generated:

backup.fileName = "backups/${GeneratedFileName}.${BackupNumber}"

Works.

zen0wu commented 10 years ago

Sure. This can be done. So one of your design goal is to make the backup in other directory? Like somewhere else under the workspace?

Also, better rename the filename to fileName, and this backup config is at the root level of config, right? Like

greed {
  backup {
    ...
  }
}

I'm busy with other stuff recently. If you've got time, you can take some time to implement this.

vexorian commented 10 years ago
vexorian commented 10 years ago

I decided that at least for now allowing custom folders was too much trouble for the benefit. But this PR allows changing the format of the backup file name.

vexorian commented 10 years ago

Now that there is a backup section in config, we might as well allow to change the backup limit as opposed to hard coded BACKUP_NUM

vexorian commented 10 years ago

Squashed the commits now that I managed to customize folder too.

wookayin commented 10 years ago

Cool!

zen0wu commented 10 years ago

Cool!