CommandItem

Bases: cursesmenu.items.ExternalItem

class cursesmenu.items.CommandItem(text, command, arguments=None, menu=None, *, should_exit=False, override_index=None, stdout_filepath=None, **kwargs)[source]

A menu item that runs a shell command using subprocess.run.

Parameters
  • text (str) – The text for the menu item.

  • command (str) – The shell command to run when the item is selected.

  • arguments (Optional[List[str]]) – Additional arguments passed to the command.

  • menu (Optional[Any]) – The menu that this item belongs to

  • should_exit (bool) – Whether the menu will exit when this item is selected

  • stdout_filepath (Optional[Any]) – A filepath that the stdout for the command will be written to

  • kwargs (Any) – A list of kwargs to be passed to subprocess.run

action()[source]

Run the command using subprocess.run.

Return type

None

get_return()[source]

Get the exit status of the command or None if it hasn’t been run.

Return type

Optional[int]