# `DalaDev.Utils`
[🔗](https://github.com/manhvu/dala_dev/blob/main/lib/dala_dev/utils.ex#L1)

Shared utility functions used across the dala_dev codebase.

This module centralizes common operations to reduce duplication
and ensure consistent behavior across modules.

# `adb_available?`

```elixir
@spec adb_available?() :: boolean()
```

Checks if ADB is available in the system PATH.

# `command_available?`

```elixir
@spec command_available?(String.t()) :: boolean()
```

Checks if a command is available in the system PATH.

# `compile_regex`

```elixir
@spec compile_regex(String.t(), String.t()) :: Regex.t()
```

Compiles a regex pattern with the given options.

Centralizes regex compilation to avoid duplicating `Regex.compile!/2` calls
and provides a single place to handle compilation errors.

## Examples

    iex> DalaDev.Utils.compile_regex("hello\s+world")
    ~r/hello\s+world/

# `ensure_dir`

```elixir
@spec ensure_dir(String.t()) :: :ok | {:error, term()}
```

Ensures a directory exists, creating it if necessary.

Returns `:ok` on success, `{:error, reason}` on failure.

# `format_bytes`

```elixir
@spec format_bytes(non_neg_integer()) :: String.t()
```

Formats a byte size into a human-readable string.

# `parse_adb_devices_output`

```elixir
@spec parse_adb_devices_output(String.t()) :: [String.t()]
```

Parses ADB devices output into a list of device identifiers.

Expects output from `adb devices` command.

# `run_adb_for_device`

```elixir
@spec run_adb_for_device(String.t(), [String.t()], keyword()) ::
  {:ok, String.t()} | {:error, term()}
```

Runs an ADB command for a specific device with timeout.

Convenience wrapper that prepends `-s <serial>` to the arguments.

# `run_adb_with_timeout`

```elixir
@spec run_adb_with_timeout(
  [String.t()],
  keyword()
) :: {:ok, String.t()} | {:error, term()}
```

Safely runs an ADB command with timeout protection.

Returns `{:ok, output}` on success, `{:error, reason}` on failure.

## Options

- `:timeout` - timeout in milliseconds (default: 8000)
- `:stderr_to_stdout` - whether to merge stderr (default: true)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
