Skip to content

Latest commit

 

History

History
162 lines (112 loc) · 4.79 KB

README.md

File metadata and controls

162 lines (112 loc) · 4.79 KB

🍞 Brot

Image of Brot

Brot is a simple configurable program which does repetitive tasks I do not want to do by myself anymore.

In case you are wondering what the heck this is all about and about its limited usefulness and special use cases at the moment because I am mainly using this project to learn Golang from scratch.

Configuration

Brot will look for a configuration file named brot.yaml at following locations in the following order (the last in list wins prioritization):

  • /etc/brot
  • $HOME/.config
  • In the same directory where the binary is located at.
  • Passed as flag --config or -c.
---
apiVersion: v1
defaults:
  loglevel: debug
  logformat: text

apiVersion: Brot uses semantic versioning and this value describes to which major version the configuration file is compatible to.

loglevel: Possible values are debug, info, warn and error.

logformat: Possible values are text or json.

Global flags

--config, -c Path to configuration file to use.

--verbosity, -v Integer value for verbosity, the higher the value the more verbose. 1 ~ error, 2 ~ warn, 3 ~ info, 4 ~ debug

Sub command: relocate

Use this sub command to move or copy files around using rules. E.g. to tidy up your download directory.

Brot will not change anything in case there is already a file in the destination directory with the same name.

Configuration: relocate

All relocation rules have to specified as YAML list with the key relocate: in the root. Each relocation item needs following values to execute properly.

relocate:
  - name: move pdfs
    src: $HOME/Downloads
    dst: $HOME/Documents
    patterns:
      - "*.pdf"
    mode: move
  - name: copy pictures
    src: $HOME/Downloads
    dst: /media/USB/Pictures
    patterns:
      - "*.jpg"
      - "*.png"
    mode: copy

name: Human readable alias for each rule. It must not be unique, but it helps if it actually is.

src: Directory to read files from. Does not follow any symbolic links if found.

dst: Directory to relocate files to. Brot will not create the destination directory for you if it does not exist.

Environment variable expansion is possible for values in src: and dst:. E.g. $HOME expands to the user's home directory if set.

patterns: Specify patterns: to target only specific files in src:. Leave it empty to match all files.

mode: Specify either move or copy.

Flags: relocate

--dry-run, -d Just print out possible matches but do not move/copy anything.

Sub command: cleanup

Use this sub command to remove files around using rules. E.g. to tidy up your download directory.

Configuration: cleanup

All cleanup rules have to specified as YAML list with the key cleanup: in the root. Each cleanup item needs following values to execute properly.

cleanup:
  - name: mac os foo
    src: $HOME/Downloads
    patterns:
      - ".DS_Store"
      - "._.DS_Store"

name: Human readable alias for each rule. It must not be unique, but it helps if it actually is.

src: Directory to read files from. Does not follow any symbolic links if found.

Environment variable expansion is possible for values in src:. E.g. $HOME expands to the user's home directory if set.

patterns: Specify patterns: to target only specific files in src:. Leave it empty to match all files.

Flags: cleanup

--dry-run, -d Just print out possible matches but do not remove anything. configuration

Sub command: completion

Use this sub command to generate shell completions for Bash, Fish, PowerShell or Zsh which can be sourced.

brot completion [bash|fish|powershell|zsh]

Build from source

# get the source
$ go get github.com/siwei-luo/brot

# (optional) update dependencies
$ go get -u
$ go mod tidy

# build for your current environment
# set GOOS and GOARCH to cross compile for other targets
$ go build github.com/siwei-luo/brot

Logo

The logo is derived from the original version created by Takuya Ueda licensed under CC 3.0 Attributions license.

License

Copyright © 2021-2024 Siwei Luo [email protected]

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.