translate_compound_command

Function translate_compound_command 

Source
pub fn translate_compound_command(
    input: &str,
    from_os: Os,
    to_os: Os,
) -> Result<TranslationResult, TranslationError>
Expand description

Translate a compound command containing operators like &&, ||, ;, or |

This function splits the input by operators, translates each command individually, and then joins them back together.

§Arguments

  • input - The compound command string to translate
  • from_os - The source operating system
  • to_os - The target operating system

§Returns

  • Ok(TranslationResult) - The translated compound command
  • Err(TranslationError) - Error if any command translation fails

§Example

use cmdx::{translate_compound_command, Os};

let result = translate_compound_command("dir && cls", Os::Windows, Os::Linux);
assert!(result.is_ok());
let result = result.unwrap();
assert!(result.command.contains("ls"));
assert!(result.command.contains("clear"));