Skip to main content

detect_format

Function detect_format 

Source
pub fn detect_format(path: &str, content: &str) -> Result<ImportFormat>
Expand description

Detect the import format from file extension and content.

Detection order:

  1. .cast extension → error (asciinema not supported)
  2. .sh or .bash extension → BashScript
  3. Shebang lines (#!/bin/bash, #!/bin/sh, #!/usr/bin/env bash) → BashScript
  4. Lines matching : TIMESTAMP:DURATION;CMDZshHistory
  5. Lines starting with - cmd: FishHistory
  6. Default fallback → BashHistory

§Errors

Returns an error if the file is an unsupported format (e.g., .cast files).

§Panics

Panics if the internal regex pattern is invalid (should never happen).