Git Product home page Git Product logo

simple-exec's Introduction

SimpleExec

NuGet version Build status

SimpleExec is a .NET library that runs external commands. It wraps System.Diagnostics.Process to make things easier.

SimpleExec intentionally does not invoke the system shell.

The command is echoed to standard error (stderr) for visibility.

Platform support: .NET Standard 1.3 and upwards.

Quick start

using static SimpleExec.Command;
Run("foo.exe", "arg1 arg2");

API

Run

Run("foo.exe");
Run("foo.exe", "arg1 arg2", "my-directory", noEcho: true);

await RunAsync("foo.exe");
await RunAsync("foo.exe", "arg1 arg2", "my-directory", noEcho: true);

Read

var output1 = Read("foo.exe");
var output2 = Read("foo.exe", "arg1 arg2", "my-directory", noEcho: true);

var output3 = await ReadAsync("foo.exe");
var output4 = await ReadAsync("foo.exe", "arg1 arg2", "my-directory", noEcho: true);

Exceptions

If the command has a non-zero exit code, a NonZeroExitCodeException is thrown with an int ExitCode property and a message in the form of:

$"The process exited with code {ExitCode}."

Windows

Sometimes, for whatever wonderful reasons, it's necessary to run a different command on Windows. For example, when running Yarn, some combination of mysterious factors may require that you explicitly run cmd.exe with Yarn as an argument, rather than running Yarn directly. The optional windowsNames and windowsArgs parameters may be used to specify a different command name and arguments for Windows:

Run("yarn", windowsName: "cmd", windowsArgs: "/c yarn");

Run by Gregor Cresnar from the Noun Project.

simple-exec's People

Contributors

adamralph avatar pauldotknopf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.