New Atata.Cli and Atata.Cli.Npm .NET libraries are released to help you work with CLI programs.
Atata.Cli
Atata.Cli is a .NET library that provides an API for CLI.
Find out more information on the library on Atata.Cli GitHub repository README page.
Features
- Provides an abstraction over
System.Diagnostics.Process
withCliCommand
andProgramCli
classes. - Has ability to execute CLI through command shell (cmd/bash).
- Provides synchronous and asynchronous API methods.
- Works on Windows, Linux and macOS.
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");
Atata.Cli.Npm
Atata.Cli.Npm is a .NET library that provides an API for NPM.
Find out more information on the library on Atata.Cli.Npm GitHub repository README page.
Features
- Checks whether NPM is installed.
- Checks whether package is installed.
- Gets installed package version.
- Installs package.
- Uninstalls package.
The main class is NpmCli
located in Atata.Cli.Npm
namespace.
There is also GlobalNpmPackageCli<TCli>
, which can be used as a base class of specific NPM package CLI.
Usage
Check NPM is Installed
bool isNpmInstalled = new NpmCli()
.IsItInstalled();
Ensure NPM is Installed
new NpmCli()
.EnsureItIsInstalled();
If NPM isn’t installed, throws NpmNotFoundException
.
Install Package Into Directory
NpmCli.InDirectory("some/dir")
.Install("npm-package-name-1")
.Install("npm-package-name-2", "1.2.3");
Install Package Globally
new NpmCli()
.Install("html-validate", global: true);
Install Package If Missing
NpmCli.InBaseDirectory()
.InstallIfMissing("html-validate", global: true);
Check Package is Installed
bool isPackageInstalled = new NpmCli()
.IsInstalled("html-validate", global: true);
Check Specific Package Version is Installed
bool isPackageVersionInstalled = new NpmCli()
.IsInstalled("html-validate", "5.0.0", global: true);
Get Installed Package Version
string packageVersion = new NpmCli()
.GetInstalledVersion("html-validate", global: true);
Uninstall Package
new NpmCli()
.Uninstall("html-validate", global: true);