Giter Club home page Giter Club logo

clirunner's Introduction

Exemplo de uso:

// Linux '.dll' to windows.
[DllImport("CliRunner.so", EntryPoint = "Run")]
public unsafe static extern int Run(char* command_ptr, char* output_ptr, char* environment_vars, int output_buffer_size, bool wait_for_exit, bool redirect_stdin, bool redirect_stdout, bool redirect_stderr, bool use_shell, bool create_no_window, bool use_powershell, bool force_utf8);
public unsafe static void Main()
{
    fixed (char* command = CliRunner.IsUnix() ? "ifconfig" : "ipconfig")
    {
        int    buffer_size = 8192;
        string stdout      = new('.', buffer_size);
        fixed (char* stdout_ptr = stdout)
        {
            fixed (char* env_ptr = "{\"KEY1\":\"VALUE1\"}")
            {
                // arguments: command, output, environment_vars, buffer_size, wait_for_exit, redirect_stdin, redirect_stdout, redirect_stderr, use_shell,     create_no_window use_powershell, force_utf8
                int stdout_size = CliRunner.Run(command, stdout_ptr, env_ptr, buffer_size, true, false, true, true, false, true, true, false);
                Console.WriteLine(stdout[..stdout_size]);
                if (!CliRunner.IsUnix())
                {
                    Console.ReadLine();
                }
            }
        }
    }
}

Como buildar?

// .NET 8(Native AOT)
dotnet publish -c Release -r linux-x64 -o "YOUR_PATH"
dotnet publish -c Release -r win-x64 -o "YOUR_PATH"

clirunner's People

Contributors

ruancardoso avatar

Watchers

 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.