GithubHelp home page GithubHelp logo

orhankalyon / atata-cli Goto Github PK

View Code? Open in Web Editor NEW

This project forked from atata-framework/atata-cli

0.0 0.0 0.0 115 KB

.NET library that provides an API for CLI.

License: Apache License 2.0

C# 100.00%

atata-cli's Introduction

Atata.Cli

NuGet GitHub release Build status Slack Atata docs Twitter

Atata.Cli is a .NET library that provides an API for CLI.

The package targets .NET Standard 2.0, which supports .NET 5+, .NET Framework 4.6.1+ and .NET Core/Standard 2.0+.

Table of Contents

Features

  • Provides an abstraction over System.Diagnostics.Process with CliCommand and ProgramCli classes.
  • Has ability to execute CLI through command shell: cmd, sh, bash, sudo, etc.
  • Provides synchronous and asynchronous API methods.
  • Works on Windows, Linux and macOS.

Installation

Install Atata.Cli NuGet package.

  • Package Manager:

    Install-Package Atata.Cli
    
  • .NET CLI:

    dotnet add package Atata.Cli
    

Usage

Execute Command to Get Value

CliCommandResult result = new ProgramCli("dotnet")
    .Execute("--version");

string version = result.Output;

Execute Command in Directory

new ProgramCli("dotnet")
    .WithWorkingDirectory("some/path")
    .Execute("build -c Release");

Execute Command Through Command Shell

new ProgramCli("npm", useCommandShell: true)
    .Execute("install -g html-validate");

The default command shell for Windows is "cmd", for other OSs it is "sh".

Execute Command Through Specific Command Shell

new ProgramCli("npm", new BashShellCliCommandFactory("-login"))
    .Execute("install -g html-validate");

or

new ProgramCli("npm")
    .WithCliCommandFactory(new BashShellCliCommandFactory("-login"))
    .Execute("install -g html-validate");

Set Default Shell CLI Command Factory

The default shell CLI command factory can be set in a global setup/initialization method.

Set for Any Operating System

ProgramCli.DefaultShellCliCommandFactory = new BashShellCliCommandFactory();

Set Specific to Operating System

ProgramCli.DefaultShellCliCommandFactory = OSDependentShellCliCommandFactory
    .UseCmdForWindows()
    .UseForOtherOS(new BashShellCliCommandFactory("-login"));

CLI Command Factories

There are several predefined classes that implement ICliCommandFactory:

  • DirectCliCommandFactory - executes the command directly. The default one.
  • CmdShellCliCommandFactory - executes the command through the Windows cmd shell program.
  • BashShellCliCommandFactory - executes the command through the Unix Bash shell program.
  • ShShellCliCommandFactory - executes the command through the Unix sh shell program.
  • SudoShellCliCommandFactory - executes the command through the Unix sudo shell program.
  • OSDependentShellCliCommandFactory - executes the command through one of the registered in it shell ICliCommandFactory instances depending on the current operating system.
  • UnixShellCliCommandFactory - executes the command through the specified Unix shell program.
  • ShellCliCommandFactory - base factory class that executes the command through the specified shell program.

Feedback

Any feedback, issues and feature requests are welcome.

If you faced an issue please report it to Atata.Cli Issues, ask a question on Stack Overflow using atata tag or use another Atata Contact way.

SemVer

Atata Framework follows Semantic Versioning 2.0. Thus backward compatibility is followed and updates within the same major version (e.g. from 1.3 to 1.4) should not require code changes.

License

Atata is an open source software, licensed under the Apache License 2.0. See LICENSE for details.

atata-cli's People

Contributors

yevgeniyshunevych 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.