# SPDX-FileCopyrightText: 2021 RizinOrg <info@rizin.re>
# SPDX-License-Identifier: LGPL-3.0-only
---
name: cmd_shell
type: RZ_CMD_DESC_TYPE_GROUP
commands:
  - name: ascii
    summary: Print ASCII table
    cname: cmd_shell_ascii_table
    args: []
  - name: date
    summary: Get current date
    cname: cmd_shell_date
    args: []
  - name: diff
    summary: Compare <A> file with <B>
    cname: cmd_shell_diff
    args:
      - name: A
        type: RZ_CMD_ARG_TYPE_FILE
      - name: B
        type: RZ_CMD_ARG_TYPE_FILE
  - name: env
    cname: cmd_shell_env
    summary: Get/set environment variables
    args_str: " [<varname>[=<varvalue>]]"
    args:
      - name: varname
        optional: true
        type: RZ_CMD_ARG_TYPE_ENV
      - name: varvalue
        optional: true
        type: RZ_CMD_ARG_TYPE_STRING
    details:
      - name: Examples
        entries:
          - text: "env"
            comment: List all environment variables
          - text: "env"
            arg_str: " SHELL"
            comment: Print value of SHELL variable
          - text: "env"
            arg_str: " TMPDIR=/tmp"
            comment: Set TMPDIR to "/tmp"
      - name: Environment
        entries:
          - text: "RZ_FILE"
            comment: "currently opened file name"
          - text: "RZ_OFFSET"
            comment: "current offset (64bit value)"
          - text: "RZ_BSIZE"
            comment: "block size"
          - text: "RZ_ENDIAN"
            comment: "'big' or 'little'"
          - text: "RZ_IOVA"
            comment: "is io.va true? virtual addressing (1,0)"
          - text: "RZ_DEBUG"
            comment: "debug mode enabled? (1,0)"
          - text: "RZ_SIZE"
            comment: "file size"
          - text: "RZ_ARCH"
            comment: "value of asm.arch"
          - text: "RZ_BITS"
            comment: "arch reg size (8, 16, 32, 64)"
          - text: "RZ_BIN_LANG"
            comment: "assume this lang to demangle"
          - text: "RZ_BIN_DEMANGLE"
            comment: "demangle or not"
          - text: "RZ_BIN_PDBSERVER"
            comment: "e pdb.server"
  - name: exit
    cname: cmd_shell_exit
    summary: Exit Rizin
    args: []
  - name: ls
    cname: cmd_shell_ls
    summary: List files and directories
    args_str: " [-e -q -l -j] <dir/file>"
    args:
      - name: e
        type: RZ_CMD_ARG_TYPE_OPTION
        flags: RZ_CMD_ARG_FLAG_OPTION
        optional: true
      - name: q
        type: RZ_CMD_ARG_TYPE_OPTION
        flags: RZ_CMD_ARG_FLAG_OPTION
        optional: true
      - name: l
        type: RZ_CMD_ARG_TYPE_OPTION
        flags: RZ_CMD_ARG_FLAG_OPTION
        optional: true
      - name: j
        type: RZ_CMD_ARG_TYPE_OPTION
        flags: RZ_CMD_ARG_FLAG_OPTION
        optional: true
      - name: path
        type: RZ_CMD_ARG_TYPE_FILE
        optional: true
  - name: rm
    cname: cmd_shell_rm
    summary: Remove <file>
    args:
      - name: file
        type: RZ_CMD_ARG_TYPE_FILE
  - name: sleep
    cname: cmd_shell_sleep
    summary: Sleep for <seconds> seconds
    args:
      - name: seconds
        type: RZ_CMD_ARG_TYPE_NUM
  - name: uniq
    cname: cmd_shell_uniq
    summary: List unique strings in <filename> or from piped input
    args:
      - name: filename
        type: RZ_CMD_ARG_TYPE_FILE
        optional: true
  - name: uname
    cname: cmd_shell_uname
    summary: Provide system info
    args:
      - name: r
        type: RZ_CMD_ARG_TYPE_OPTION
        flags: RZ_CMD_ARG_FLAG_OPTION
        optional: true
  - name: echo
    summary: Display a line of text
    cname: cmd_shell_echo
    args:
      - name: strs
        type: RZ_CMD_ARG_TYPE_STRING
        flags: RZ_CMD_ARG_FLAG_ARRAY
        optional: true
  - name: clippy
    summary: echo but with a comic
    cname: cmd_shell_clippy
    args:
      - name: strs
        type: RZ_CMD_ARG_TYPE_STRING
        flags: RZ_CMD_ARG_FLAG_ARRAY
        optional: true
  - name: cp
    summary: Copy <src> file to <dst>
    cname: cmd_shell_cp
    args:
      - name: src
        type: RZ_CMD_ARG_TYPE_FILE
      - name: dst
        type: RZ_CMD_ARG_TYPE_STRING
  - name: cd
    summary: Change directory to <dir>
    cname: cmd_shell_cd
    args:
      - name: dir
        type: RZ_CMD_ARG_TYPE_FOLDER
        optional: true
  - name: cat
    summary: Print contents of <file>
    cname: cmd_shell_cat
    args:
      - name: file
        type: RZ_CMD_ARG_TYPE_FILE
  - name: mv
    summary: Move <src> file to <dst>
    cname: cmd_shell_mv
    args:
      - name: src
        type: RZ_CMD_ARG_TYPE_FILE
      - name: dst
        type: RZ_CMD_ARG_TYPE_STRING
  - name: mkdir
    summary: Create a directory <dir>
    cname: cmd_shell_mkdir
    args_str: " [-p] <dir>"
    args:
      - name: p
        type: RZ_CMD_ARG_TYPE_OPTION
        flags: RZ_CMD_ARG_FLAG_OPTION
        optional: true
      - name: dir
        type: RZ_CMD_ARG_TYPE_STRING
  - name: pwd
    summary: Show the present working directory
    cname: cmd_shell_pwd
    args: []
  - name: sort
    summary: Sort the contents of <file> or from piped input
    cname: cmd_shell_sort
    args:
      - name: file
        type: RZ_CMD_ARG_TYPE_FILE
        optional: true
  - name: clear
    summary: Clear screen/console
    cname: cmd_shell_clear
    args: []
  - name: cls
    summary: clear
    cname: cmd_shell_cls
    handler: cmd_shell_clear
    args: []
  - name: flush
    summary: Flush console
    cname: cmd_shell_flush
    args: []
  - name: which
    cname: cmd_shell_which
    summary: Which shell command
    args:
      - name: command
        type: RZ_CMD_ARG_TYPE_STRING
  - name: fortune
    summary: Show the random fortune message
    cname: cmd_shell_fortune
    args: []
  - name: pkill
    cname: cmd_shell_pkill
    summary: Kill process by name
    args:
      - name: name
        type: RZ_CMD_ARG_TYPE_STRING
  - name: ver
    summary: Show version information
    type: RZ_CMD_DESC_TYPE_GROUP
    subcommands:
      - name: ver
        summary: Show version info
        cname: show_version_info
        args: []
        type: RZ_CMD_DESC_TYPE_ARGV_STATE
        modes:
          - RZ_OUTPUT_MODE_STANDARD
          - RZ_OUTPUT_MODE_QUIET
          - RZ_OUTPUT_MODE_JSON
      - name: vernum
        summary: Show numeric version
        cname: show_version_numeric
        args: []
      - name: vermajor
        summary: Show major version
        cname: show_version_major
        args: []
      - name: verminor
        summary: Show minor version
        cname: show_version_minor
        args: []
      - name: verpatch
        summary: Show patch version
        cname: show_version_patch
        args: []
  - name: time
    summary: Calculate time taken to run a command
    cname: calculate_command_time
    args:
      - name: cmd
        type: RZ_CMD_ARG_TYPE_CMD
  - name: inittime
    summary: Print init time values
    cname: print_init_time_values
    args: []
