custom_cli
summary: add a custom command-line interpreter
- description:
Illustrates how one can add command-line interpreters to IDA
This custom interpreter doesn’t actually run any code; it’s there as a ‘getting started’. It provides an example tab completion support.
level: advanced
Attributes
Classes
cli_t wrapper class. |
Functions
|
Module Contents
- class custom_cli.mycli_t
Bases:
ida_kernwin.cli_tcli_t wrapper class.
This class allows you to implement your own command line interface handlers.
- flags = 0
- sname = 'pycli'
- lname = 'Python CLI'
- hint = 'pycli hint'
- OnExecuteLine(line)
The user pressed Enter. The CLI is free to execute the line immediately or ask for more lines.
This callback is mandatory.
- Parameters:
line – typed line(s)
- Returns:
Boolean: True-executed line, False-ask for more lines
- OnKeydown(line, x, sellen, vkey, shift)
A keyboard key has been pressed This is a generic callback and the CLI is free to do whatever it wants.
This callback is optional.
- Parameters:
line – current input line
x – current x coordinate of the cursor
sellen – current selection length (usually 0)
vkey – virtual key code. if the key has been handled, it should be returned as zero
shift – shift state
- Returns:
None - Nothing was changed
- Returns:
tuple(line, x, sellen, vkey): if either of the input line or the x coordinate or the selection length has been modified.
- Returns:
It is possible to return a tuple with None elements to preserve old values. Example: tuple(new_line, None, None, None) or tuple(new_line)
- completions = ['bonnie & clyde', 'bonfire of the vanities', 'bongiorno']
- OnFindCompletions(line, x)
The user pressed Tab. Return a list of completions
This callback is optional.
- Parameters:
line – the current line (string)
x – the index where the cursor is (int)
- Returns:
None if no completion could be generated, otherwise a tuple: (completions : Sequence[str], hints : Sequence[str], docs: Sequence[str],
match_start: int, match_end: int)
- custom_cli.nw_handler(code, old=0)
- custom_cli.mycli
- custom_cli.when = 11