Honoring Asian Pacific American Heritage Month. See how.

fx format-code

runs source formatters on modified files

Usage: fx format-code
          [--dry-run] [--verbose] [--all]
          [--files=FILES,[FILES ...]]
          [--git] [--changed-lines] [-- PATTERN]

  --dry-run Stops the program short of running the formatters
  --all     Formats all code in the git repo under the current working
  --args    Formats the configured build's |args.gn|
  --files   Allows the user to specify files.  Files are comma separated.
            Globs are dealt with by bash; fx format-code "--files=foo/*" will
            work as expected.
  --target  Allows the user to specify a gn target.
  --git     The default; it uses `git diff` against the newest parent
            commit in the upstream branch (or against HEAD if no such commit
            is found).  Files that are locally modified, staged or touched by
            any commits introduced on the local branch are formatted.
            Format changed lines only. Only supported on a subset of languages
            (currently, just C++). Unsupported languages will continue to have
            the entire file formatted. "Changes" are relative to the git
            commit that would be used by "--git".
  --verbose Print all formatting commands prior to execution.
            For --all or --git, passes along -- PATTERN to `git ls-files`
            to filter what files are affected.

Supported Languages: C, C++, cml, Dart, FIDL, GN, Go, Python, Rust, JSON

format-code source code