updated readme and added default ini file

This commit is contained in:
Philipp Häfelfinger 2019-07-14 21:55:17 +02:00
parent 642a20c56f
commit dffd7ee666
4 changed files with 103 additions and 2 deletions

View File

@ -1,3 +1,98 @@
# SideCarJpegCleaner # 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. 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!**

Binary file not shown.

View File

@ -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)

View File

@ -16,7 +16,7 @@ import (
) )
var ( 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") dryRun = flag.Bool("dryRun", true, "If set to true, all actions are run except the real filesystem modifications")
) )