Skip to content

Fix json label replace (#1702) - #2501

Merged
AucaCoyan merged 2 commits into
espanso:devfrom
gcailly:fix-json-label-replace-1702
Oct 5, 2025
Merged

AucaCoyan merged 2 commits into
espanso:devfrom
gcailly:fix-json-label-replace-1702

Conversation

@gcailly

@gcailly gcailly commented Oct 4, 2025

Copy link
Copy Markdown
Contributor

The espanso match list --json command was incorrectly showing the label value in the replace field when a label was present.

Now the JSON output correctly shows the actual replacement text in the replace field and the label separately in the label field.

Fixes #1702

…panso#2483)

When running commands like `espanso service --help` or `espanso package --help`,
the CLI was displaying the main application help instead of the specific
subcommand help.

This was caused by using `clap_instance.print_help()` which always prints
the root command help, instead of using `err.exit()` which properly handles
contextual help for subcommands.

Fix: Use `err.exit()` to let Clap handle contextual help display.

Fixes espanso#2483
@gcailly
gcailly requested a review from AucaCoyan as a code owner October 4, 2025 08:44
@gcailly
gcailly force-pushed the fix-json-label-replace-1702 branch from 8509b67 to 637c190 Compare October 4, 2025 08:52
@gcailly
gcailly force-pushed the fix-json-label-replace-1702 branch from 637c190 to ac9e9a6 Compare October 4, 2025 08:55
@gcailly gcailly changed the title Fix json label replace 1702 Fix json label replace (#1702) Oct 4, 2025
@AucaCoyan

Copy link
Copy Markdown
Collaborator

perfect!
Just to know what are the default results, those are:

[
  {
    "triggers": [
      ":espanso"
    ],
    "replace": "Hi there!",
    "label": null
  },
  {
    "triggers": [
      ":date"
    ],
    "replace": "{{mydate}}",
    "label": null
  },
  {
    "triggers": [
      ":shell"
    ],
    "replace": "{{output}}",
    "label": null
  }
]
  • we are doing triggers as an array
  • and label is always added as the key, and when you don't have any value, the value is null

Those sound strange at first, but its the current implementation 👍🏼

@AucaCoyan
AucaCoyan merged commit 34829eb into espanso:dev Oct 5, 2025
sboldt1978 pushed a commit to sboldt1978/espanso that referenced this pull request Feb 11, 2026
* Fix subcommand help displaying main help instead of specific help (espanso#2483)

When running commands like `espanso service --help` or `espanso package --help`,
the CLI was displaying the main application help instead of the specific
subcommand help.

This was caused by using `clap_instance.print_help()` which always prints
the root command help, instead of using `err.exit()` which properly handles
contextual help for subcommands.

Fix: Use `err.exit()` to let Clap handle contextual help display.

Fixes espanso#2483

* Fix JSON output showing label in replace field (espanso#1702)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Label Field Incorrectly Interpreted as Replace Field in espanso match list -j Output

2 participants