Function: sops--format-for

sops--format-for is a natively compiled function defined in sops.el.

Signature

(sops--format-for FILENAME)

Documentation

Return the sops--example-for key for FILENAME, or nil if unknown.

Standard extensions ("yaml"/"yml"/"json"/"env"/"ini"/"txt") win first so a .txt file always picks the txt greeting stub, even when the user also has a sops-input-type-overrides entry mapping the path to a sops parser (e.g. for encrypt to succeed). For non-standard extensions like .secrets, sops-input-type-overrides is the fallback, mapping the path to one of the recognized stub keys.

Returns one of "yaml", "json", "dotenv", "ini", "txt", or nil. The first four are also valid sops --input-type values;
"txt" is sops-mode-only -- sops itself doesn't parse a txt
input-type, so .txt creators must configure sops-input-type-overrides (e.g. ("\\.enc\\.txt\\" . "yaml")') for encrypt to succeed.

Source Code

;; Defined in /nix/store/vihl6lkzddv9xrsrsznvqdjq27g2i30p-emacs-packages-deps/share/emacs/site-lisp/elpa/sops-20260920.2121/sops.el
(defun sops--format-for (filename)
  "Return the `sops--example-for' key for FILENAME, or nil if unknown.
Standard extensions (\"yaml\"/\"yml\"/\"json\"/\"env\"/\"ini\"/\"txt\") win
first so a `.txt' file always picks the txt greeting stub, even when the
user also has a `sops-input-type-overrides' entry mapping the path
to a sops parser (e.g. for encrypt to succeed).  For non-standard
extensions like `.secrets', `sops-input-type-overrides' is the
fallback, mapping the path to one of the recognized stub keys.

Returns one of \"yaml\", \"json\", \"dotenv\", \"ini\", \"txt\", or
nil.  The first four are also valid sops `--input-type' values;
\"txt\" is sops-mode-only -- sops itself doesn't parse a `txt'
input-type, so `.txt' creators must configure
`sops-input-type-overrides' (e.g. `(\"\\\\.enc\\\\.txt\\\\'\" . \"yaml\")') for
encrypt to succeed."
  (let ((ext (and filename (file-name-extension filename))))
    (or (pcase ext
          ((or "yaml" "yml") "yaml")
          ("json"            "json")
          ("env"             "dotenv")
          ("ini"             "ini")
          ("txt"             "txt"))
        (sops--input-type-for filename))))