> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lynxhub.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Card main methods

> Implement backend methods to handle execution commands, cache arguments, and clean up files.

Backend card methods control how LynxHub runs your CLI processes, reads saved arguments from disk files, and handles uninstallation cleanups.

***

## Execution commands

* **Method**: `getRunCommands(): Promise<string | string[]>`
* **Responsibility**: Invoked when the user clicks the card launch button. It must return a terminal command string (or array of strings) to execute in the pseudo-terminal.

### Example

```javascript theme={null}
async () => {
  const installDir = utils.getInstallDir('my-card-id');
  const preCommands = utils.getExtensions_TerminalPreCommands('my-card-id');

  // Read saved configurations
  let argsString = '';
  try {
    const savedArgs = (await utils.storage.get('my_arguments_key')) || [];
    argsString = savedArgs.map(arg => `${arg.name} ${arg.value}`).join(' ');
  } catch {
    // Fallback if key does not exist
  }

  return [`cd /d "${installDir}"`, ...preCommands, `python main.py --host 127.0.0.1 ${argsString}`];
};
```

***

## Arguments cache

If you prefer to cache argument configurations in a local config file rather than standard database storage, implement the argument cache methods:

* **Methods**: `readArgs(): Promise<ChosenArgument[]>` and `saveArgs(args: ChosenArgument[]): Promise<void>`
* **Responsibility**: Reads configuration parameters from disk files, and saves chosen settings back to the configuration files.

### Example

```javascript theme={null}
const methods = {
  readArgs: async () => {
    const configDir = utils.getConfigDir();
    // Read and parse options from settings.json inside configDir
    return [];
  },
  saveArgs: async args => {
    const configDir = utils.getConfigDir();
    // Write the args array to disk inside configDir
  },
};
```

***

## Custom IPC listeners

* **Method**: `mainIpc(): void`
* **Responsibility**: Invoked during application IPC configuration. Use this to bind message handlers between frontend pages and backend modules.

### Example

```javascript theme={null}
() => {
  utils.ipc.handle('module:get-status', async () => {
    return {status: 'idle'};
  });
};
```

***

## Lifecycle events

Implement lifecycle state checks to tell the host app if card files exist, if updates are available, or to clean up files on removal:

* `isInstalled(): Promise<boolean>` - Check if files are located in the installation folder.
* `updateAvailable(): Promise<boolean>` - Checks if a Git pull is available in the installation folder.
* `uninstall(): Promise<void>` - Runs file removals, deletes dependencies, and clears cache on card deletion.

### Example

```javascript theme={null}
const lifecycle = {
  isInstalled: async () => {
    const runFolder = utils.getInstallDir('my-card-id');
    return runFolder !== undefined;
  },
  updateAvailable: async () => {
    const runFolder = utils.getInstallDir('my-card-id');
    if (!runFolder) return false;
    return utils.isPullAvailable(runFolder);
  },
  uninstall: async () => {
    const runFolder = utils.getInstallDir('my-card-id');
    if (runFolder) {
      await utils.trashDir(runFolder);
    }
  },
};
```
