dandavison / delta

A syntax-highlighting pager for git, diff, grep, and blame output
https://dandavison.github.io/delta/
MIT License
21.43k stars 361 forks source link

Question: detailed document about format syntax of `--blame-format <FMT>`? #1554

Closed linrongbin16 closed 8 months ago

linrongbin16 commented 8 months ago

Hi, in the delta --help output, there's --blame-format option doc:

Options:
      --blame-code-style <STYLE>
          Style string for the code section of a git blame line.

          By default the code will be syntax-highlighted with the same background color as the blame format section of the line (the background color is determined by blame-palette). E.g. setting this option to 'syntax' will syntax-highlight the code with no background color.

      --blame-format <FMT>
          Format string for git blame commit metadata.

          Available placeholders are "{timestamp}", "{author}", and "{commit}".

          [default: "{timestamp:<15} {author:<15.14} {commit:<8}"]

      --blame-palette <COLORS>
          Background colors used for git blame lines (space-separated string).

          Lines added by the same commit are painted with the same color; colors are recycled as needed.

      --blame-separator-format <FMT>
          Separator between the blame format and the code section of a git blame line.

My question is: is there any document about what syntax is the "{timestamp:<15} {author:<15.14} {commit:<8}" of --blame-format?

A more specific question is: what does {author:<15.14} mean here? 15 is the max width? or 14?

linrongbin16 commented 8 months ago

Oh I found it: https://doc.rust-lang.org/std/fmt/#formatting-parameters,

There's one line about the <FMT> syntax in --help output:

Options --line-numbers-left-format and --line-numbers-right-format allow you to change the contents of the line number columns. Their values are arbitrary format strings, which are allowed to contain the placeholders {nm} for the line number associated with the old version of the file and {np} for the line number associated with the new version of the file. The placeholders support a subset of the string formatting syntax documented here: https://doc.rust-lang.org/std/fmt/#formatting-parameters. Specifically, you can use the alignment and width syntax.

emmmm, since I'm not familiar with rust, still not sure what does {author:<15.14} mean?

In rust doc, it seems the dot . is for number precision, but I'm not sure here.