Method

report.importStyleSheets

Import GnuCash's style sheets from the text of its stylesheets-2.0 file, read as data, never run.

Imports the style sheets from GnuCash's stylesheets-2.0 file, given as its text; the server never reads a path and never runs the text. An entry that names a predefined style sheet (Default, Easy, …) holds the user's changes to it; any other name is a user style sheet. skipped says why an entry was left out: malformed, untranslated (a style sheet template red-ale does not have), exists (the Configuration already has an entry for that name, so edits made in red-ale are kept), invalid-option or unchanged (a predefined style sheet at its defaults). Image options are kept but not rendered. With dryRun nothing is written.

Examples

Example: with no book.

JSON-RPC

Request:

{"jsonrpc":"2.0","id":1,"method":"report.importStyleSheets","params":{"text":"(let ((template (gnc:html-style-sheet-template-find \"Footer\")))\n  (if template\n    (let ((options ((gnc:html-style-sheet-template-options-generator template))))\n\n; Section: Tables\n\n(let ((option (gnc:lookup-option options\n                                 \"Tables\"\n                                 \"Table border width\")))\n  ((lambda (o) (if o (gnc:option-set-value o '2.0))) option))\n\n (gnc:restore-html-style-sheet \"Acme\" \"Footer\" options))))\n"}}

Response:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "dryRun": false,
    "imported": [
      {
        "line": 1,
        "styleSheet": {
          "name": "Acme",
          "template": "Footer",
          "predefined": false,
          "…": "…"
        },
        "…": "…"
      }
    ],
    "skipped": []
  }
}

Command line

red-ale exec report.importStyleSheets '{"text":"(let ((template (gnc:html-style-sheet-template-find \"Footer\")))\n  (if template\n    (let ((options ((gnc:html-style-sheet-template-options-generator template))))\n\n; Section: Tables\n\n(let ((option (gnc:lookup-option options\n                                 \"Tables\"\n                                 \"Table border width\")))\n  ((lambda (o) (if o (gnc:option-set-value o '\''2.0))) option))\n\n (gnc:restore-html-style-sheet \"Acme\" \"Footer\" options))))\n"}'

It prints:

{
  "dryRun": false,
  "imported": [
    {
      "line": 1,
      "styleSheet": {
        "name": "Acme",
        "template": "Footer",
        "predefined": false,
        "…": "…"
      },
      "…": "…"
    }
  ],
  "skipped": []
}

MCP tool call

Tool call:

{"name":"report.importStyleSheets","arguments":{"text":"(let ((template (gnc:html-style-sheet-template-find \"Footer\")))\n  (if template\n    (let ((options ((gnc:html-style-sheet-template-options-generator template))))\n\n; Section: Tables\n\n(let ((option (gnc:lookup-option options\n                                 \"Tables\"\n                                 \"Table border width\")))\n  ((lambda (o) (if o (gnc:option-set-value o '2.0))) option))\n\n (gnc:restore-html-style-sheet \"Acme\" \"Footer\" options))))\n"}}

Result:

{
  "structuredContent": {
    "dryRun": false,
    "imported": [
      {
        "line": 1,
        "styleSheet": {
          "name": "Acme",
          "template": "Footer",
          "predefined": false,
          "…": "…"
        },
        "…": "…"
      }
    ],
    "skipped": []
  }
}

Effect: write, on the Configuration only.

Params

Params of report.importConfigurations and report.importStyleSheets.

  • text (string, required): The file's text: GnuCash's saved-reports-2.8 (else saved-reports-2.4), or stylesheets-2.0, from its user data directory. It is read as data and never run.
  • dryRun (boolean): Report what would be imported without writing the Configuration.

Result

The result of report.importStyleSheets.

  • dryRun (boolean, required): True when nothing was written.
  • imported (array of ImportedStyleSheet, required): The style sheets imported (or that would be), in file order.
  • skipped (array of SkippedEntry, required): The entries skipped, in file order.