diff --git a/README.md b/README.md index a01992a..4eb92b9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,98 @@ # SideCarJpegCleaner -A small tool to clean up a folder with raw and jpeg files. It scans the directory for jpg files and removes all without a corresponding raw file. \ No newline at end of file +A small tool to clean up a folder with raw and jpeg files. It scans the directory for jpg files and removes all without a corresponding raw file. + +## Dependencies + +There are some external dependencies to build the application. + +- logrus: This is a little logging library that is quite handy +- iniflags: The iniflags makes handling configuration files and applications parameters quite easy. + +## Get the source + +To get the latest version, you should ``git clone https://git.haefelfinger.net/piwigo/SideCarJpegCleaner.git`` to +your local disk or into your local go source directory by using ``go get git.haefelfinger.net/piwigo/SideCarJpegCleaner`. + +### GO modules + +The repository supports gomodules so the modules should be resolved automatically during build or test run. +But just in case, here are the manual commands to install them. This is needed if you put this repo inside the GOPATH +as this sets the module config to ignore. + +To get all dependencies at once: + +``` +go get ./... +``` + +### Manual dependency installation + +You may install the dependencies manually with the following commands +or just use the command under "GO modules" to get all dependencies. + +``` +go get github.com/sirupsen/logrus +go get github.com/vharitonsky/iniflags +``` + +## Build + +Build the main executable by using the following command. By default it gets the name SideCarJpegCleaner +but can be renamed to your favorite application name. + +``` +go build go build cmd/SideCarJpegCleaner/SideCarJpegCleaner.go +``` + +## Configuration + +### Command line + +You get the following help information to the command line by using: + +``` +./SideCarJpegCleaner -help +``` + +The following options are supported to run the application from the command line. + +``` +Usage of ./SideCarJpegCleaner: + -allowMissingConfig + Don't terminate the app if the ini file cannot be read. + -allowUnknownFlags + Don't terminate the app if ini file contains unknown flags. + -config string + Path to ini config for using in go flags. May be relative to the current executable path. + -configUpdateInterval duration + Update interval for re-reading config file set via -config flag. Zero disables config file re-reading. + -dryRun + If set to true, all actions are run except the real filesystem modifications (default true) + -dumpflags + Dumps values for all flags defined in the app into stdout in ini-compatible syntax and terminates the app. + -imagesRootPath string + This is the images root path that should be cleaned. + -logLevel string + The minimum log level required to write out a log message. (panic,fatal,error,warn,info,debug,trace) (default "info") +``` + +### Configuration file + +It is also possible to use a configuration file to save the settings to be used with multiple directories. +To use configuration files, just copy the default one and edit the parameters to your wish. + +``` +cp ./configs/defaultConfig.ini ./localConfig.ini +nano ./localConfig.ini +``` + +## Run the cleaner + +Finally you may run the application using the following example command. + +``` +./SideCarJpegCleaner -config=./localConfig.ini +``` + +**It is recommendet to do a dry run first!** \ No newline at end of file diff --git a/SideCarJpegCleaner b/SideCarJpegCleaner index c49a5f5..1a352e4 100755 Binary files a/SideCarJpegCleaner and b/SideCarJpegCleaner differ diff --git a/configs/defaultConfig.ini b/configs/defaultConfig.ini new file mode 100644 index 0000000..06fbe41 --- /dev/null +++ b/configs/defaultConfig.ini @@ -0,0 +1,6 @@ +allowMissingConfig = false # Don't terminate the app if the ini file cannot be read. +allowUnknownFlags = false # Don't terminate the app if ini file contains unknown flags. +configUpdateInterval = 0s # Update interval for re-reading config file set via -config flag. Zero disables config file re-reading. +dryRun = true # If set to true, all actions are run except the real filesystem modifications +imagesRootPath = # This is the images root path that should be mirrored to piwigo. +logLevel = info # The minimum log level required to write out a log message. (panic,fatal,error,warn,info,debug,trace) diff --git a/internal/app/app.go b/internal/app/app.go index bb84628..2131674 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -16,7 +16,7 @@ import ( ) var ( - imagesRootPath = flag.String("imagesRootPath", "", "This is the images root path that should be mirrored to piwigo.") + imagesRootPath = flag.String("imagesRootPath", "", "This is the images root path that should be cleaned.") dryRun = flag.Bool("dryRun", true, "If set to true, all actions are run except the real filesystem modifications") )