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.ProcesswithCliCommandandProgramCliclasses. - 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);