system_command_runner 0.1.0 copy "system_command_runner: ^0.1.0" to clipboard
system_command_runner: ^0.1.0 copied to clipboard

A lightweight, testable wrapper around Process.run for executing system commands with cross-platform support and easy mocking.

example/example.dart

import 'package:system_command_runner/system_command_runner.dart';

void main() async {
  const runner = SystemCommandRunner();

  print('=== Basic Command Example ===');
  final echoResult = await runner.run('echo', ['Hello, World!']);
  print('Output: ${echoResult.stdout.trim()}');

  print('\n=== Command with Multiple Arguments ===');
  final multiArgResult = await runner.run('echo', ['Hello', 'from', 'Dart!']);
  print('Output: ${multiArgResult.stdout.trim()}');

  print('\n=== Command in Working Directory ===');
  final pwdResult = await runner.run('pwd', []);
  print('Current directory: ${pwdResult.stdout.trim()}');

  print('\n=== Command with Environment Variables ===');
  final envResult = await runner.run(
    'sh',
    ['-c', 'echo "Environment variable: \$MY_CUSTOM_VAR"'],
    environment: {'MY_CUSTOM_VAR': 'Hello from environment!'},
  );
  print('Output: ${envResult.stdout.trim()}');
}
0
likes
160
points
40
downloads

Publisher

verified publisherfluttered.io

Weekly Downloads

A lightweight, testable wrapper around Process.run for executing system commands with cross-platform support and easy mocking.

Repository (GitHub)
View/report issues

Topics

#system #command #shell #testing

Documentation

API reference

License

MIT (license)

Dependencies

meta

More

Packages that depend on system_command_runner