# SPDX-FileCopyrightText: 2025 PremadeS <emadsohail001@gmail.com>
# SPDX-License-Identifier: LGPL-3.0-only
---
name: cmd_mark
commands:
  - name: m
    cname: mark_add
    summary: Adds a mark if there are no existing marks.
    description: >
      Adds the mark to the current offset only if
      no mark covers this offset already
    args:
      - name: name
        type: RZ_CMD_ARG_TYPE_STRING
      - name: end
        type: RZ_CMD_ARG_TYPE_NUM
      - name: comment
        type: RZ_CMD_ARG_TYPE_STRING
        optional: true
  - name: m+
    cname: mark_append
    summary: Add mark.
    description: >
      Adds a mark at the current offset, replacing any existing mark with the same name.
    args:
      - name: name
        type: RZ_CMD_ARG_TYPE_STRING
      - name: end
        type: RZ_CMD_ARG_TYPE_NUM
      - name: comment
        type: RZ_CMD_ARG_TYPE_STRING
        optional: true
  - name: m-
    cname: mark_remove
    summary: Remove mark.
    description: >
      Removes marks by name.
      If <regex_pattern> is given, only marks whose name matches the regex
      are removed. Otherwise, all marks covering the current offset are removed.
    args:
      - name: regex_pattern
        type: RZ_CMD_ARG_TYPE_STRING
        optional: true
  - name: m-*
    cname: mark_remove_all
    summary: Remove all marks.
    args: []
  - name: ml
    cname: mark_list
    summary: List all marks.
    type: RZ_CMD_DESC_TYPE_ARGV_STATE
    modes:
      - RZ_OUTPUT_MODE_STANDARD
      - RZ_OUTPUT_MODE_QUIET
      - RZ_OUTPUT_MODE_JSON
      - RZ_OUTPUT_MODE_TABLE
    args: []
  - name: ml.
    cname: mark_list_at
    summary: List all marks containing the current offset.
    type: RZ_CMD_DESC_TYPE_ARGV_STATE
    modes:
      - RZ_OUTPUT_MODE_STANDARD
      - RZ_OUTPUT_MODE_QUIET
      - RZ_OUTPUT_MODE_JSON
      - RZ_OUTPUT_MODE_TABLE
    args: []
  - name: mc
    cname: mark_color
    summary: Set a color for the given mark / Show the color for the given mark.
    args:
      - name: name
        type: RZ_CMD_ARG_TYPE_FLAG
      - name: color
        type: RZ_CMD_ARG_TYPE_STRING
        optional: true
  - name: mC
    cname: mark_comment
    summary: Set a comment for the given mark. If no comment is given, it shows the current one for the mark.
    args:
      - name: name
        type: RZ_CMD_ARG_TYPE_FLAG
      - name: comment
        type: RZ_CMD_ARG_TYPE_STRING
        optional: true
  - name: mr
    cname: mark_rename
    summary: Rename mark.
    args:
      - name: old
        type: RZ_CMD_ARG_TYPE_FLAG
      - name: new
        type: RZ_CMD_ARG_TYPE_STRING
  - name: mN
    cname: mark_realname
    summary: Show the realname of the mark / Set the realname of the mark.
    description: >
      Each mark has two identifiers.
      <name> is the unique, escaped identifier used internally by Rizin.
      <realname> is the original, unescaped name, kept as given by the user.
    args:
      - name: name
        type: RZ_CMD_ARG_TYPE_FLAG
      - name: realname
        type: RZ_CMD_ARG_TYPE_STRING
        optional: true 
  - name: mm
    cname: mark_move
    summary: Move a mark to new a location.
    args:
      - name: name
        type: RZ_CMD_ARG_TYPE_FLAG
      - name: new_start
        type: RZ_CMD_ARG_TYPE_RZNUM
      - name: new_end
        type: RZ_CMD_ARG_TYPE_RZNUM
  - name: mf
    cname: mark_distance
    summary: Distance in bytes to reach the starting of mark from the current offset.
    args:
      - name: regex_pattern
        type: RZ_CMD_ARG_TYPE_STRING
  - name: md
    summary: Describe mark.
    subcommands:
      - name: md
        cname: mark_describe
        summary: Describe marks at the current offset or a named mark with distance from the offset.
        description: >
          Displays information about marks.
          Without arguments, it describes all marks that contain the current offset.
          With a <name> argument, it shows details of that mark and the distance in bytes
          from the current offset to reach the mark. If the mark begins after the
          current offset, it shows <name> - <bytes> (distance from current offset to 
          start of the mark). If the mark ends before the current offset, it shows 
          <name> + <bytes> (distance from current offset to the end of the mark).
        type: RZ_CMD_DESC_TYPE_ARGV_STATE
        modes:
          - RZ_OUTPUT_MODE_STANDARD
          - RZ_OUTPUT_MODE_TABLE
          - RZ_OUTPUT_MODE_JSON
        args:
          - name: name
            type: RZ_CMD_ARG_TYPE_FLAG
            optional: true
        details:
        - name: Usage example
          entries:
            - text: "md"
              comment: "Describe all marks containing the current offset"
            - text: "md foo"
              comment: "Describe the mark named 'foo' and show distance from current offset to reach 'foo' in bytes"
  - name: mi
    cname: mark_range
    summary: Show marks in the current block or in the next <size> bytes.
    type: RZ_CMD_DESC_TYPE_ARGV_STATE
    modes:
      - RZ_OUTPUT_MODE_STANDARD
      - RZ_OUTPUT_MODE_QUIET
      - RZ_OUTPUT_MODE_JSON
      - RZ_OUTPUT_MODE_TABLE
    args:
      - name: size
        type: RZ_CMD_ARG_TYPE_RZNUM
        optional: true
