Thanks to visit codestin.com
Credit goes to github.com

Skip to content

multi line config options #138

@quantenzitrone

Description

@quantenzitrone

currently to be able to maintain my path format i write my config with nix like this:

let
  id = x: x;

  path-format =
    # the path prefix
    "/data/music/wrtag-lossy/"

    # the first album artist
    + "{{if .Release.Artists}}"
    + id "{{(index .Release.Artists 0).Artist.Name | safepath}}"
    + "{{else}}"
    + id "Unknown Artist"
    + "{{end}}/"

    # album name
    + "{{.Release.Title | safepath}}"
    # additional album artists
    + "{{if gt (len .Release.Artists) 1}}"
    + id " ("
    #### change the first joinphrase to with except if it is a variation of "feat."
    + id "{{if eq (safepath (index .Release.Artists 0).JoinPhrase) `feat.` `feat.` `feat` `ft.` `ft` `featuring`}}"
    + id id "{{(index .Release.Artists 0).JoinPhrase | safepath}} "
    + id "{{else}}"
    + id id "with "
    + id "{{end}}"
    #### add the tail of the artiststring
    + id "{{artistsString (slice .Release.Artists 1) | safepath}}"
    + id ")"
    + "{{end}}"
    + "{{if .ReleaseDisambiguation}}"
    + id " [{{.ReleaseDisambiguation | safepath}}]"
    + "{{end}}/"

    # track number name and stuff
    + "{{pad0 2 .TrackNum}} - "
    + "{{ if .IsCompilation }}{{ artistsString .Track.Artists | safepath }} - {{ end }}"
    + "{{.Track.Title | safepath}}"

    # file extension
    + "{{.Ext}}";
in
''
  [...]
  path-format ${path-format}
  [...]
''

which evaluates to this

path-format /data/music/wrtag-lossy/{{if .Release.Artists}}{{(index .Release.Artists 0).Artist.Name | safepath}}{{else}}Unknown Artist{{end}}/{{.Release.Title | safepath}}{{if gt (len .Release.Artists) 1}} ({{if eq (safepath (index .Release.Artists 0).JoinPhrase) `feat.` `feat.` `feat` `ft.` `ft` `featuring`}}{{(index .Release.Artists 0).JoinPhrase | safepath}} {{else}}with {{end}}{{artistsString (slice .Release.Artists 1) | safepath}}){{end}}{{if .ReleaseDisambiguation}} [{{.ReleaseDisambiguation | safepath}}]{{end}}/{{pad0 2 .TrackNum}} - {{ if .IsCompilation }}{{ artistsString .Track.Artists | safepath }} - {{ end }}{{.Track.Title | safepath}}{{.Ext}}

it would be nice if i could do something like that without the detour of having to evaluate the nix code for every config change

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions