GnomeStack.Core
0.1.2
See the version list below for details.
dotnet add package GnomeStack.Core --version 0.1.2
NuGet\Install-Package GnomeStack.Core -Version 0.1.2
<PackageReference Include="GnomeStack.Core" Version="0.1.2" />
paket add GnomeStack.Core --version 0.1.2
#r "nuget: GnomeStack.Core, 0.1.2"
// Install GnomeStack.Core as a Cake Addin #addin nuget:?package=GnomeStack.Core&version=0.1.2 // Install GnomeStack.Core as a Cake Tool #tool nuget:?package=GnomeStack.Core&version=0.1.2
GnomeStack.Core
Provides extended functionality for the .NET BCL such as invoking child processes painlessly, copying directories, environment variable substitution, password generation, useful extensions to string builder, option, and result monads.
The GnomeStack.Standard
namespace is the std namespace where key classes
are, most of which are static classes that can be imported like a module or
use like a normal C# static class.
The GnomeStack.Standard
makes it easier for C# scripting or a more functional
approach to programming in C#.
The GnomeStack.Extra
contains extension and convenience methods for the BCL and
are isolated to avoid collisions with other libraries.
Both namespaces are meant to be used with the global Usings.cs
file.
using static GnomeStack.Standard.Fs;
MakeDirectory("path/to/directory");
Fs
The Fs class contains methods for File and Directory with additional methods:
- CatFiles - reads on or file files and returns a string
- CopyDirectory - recursively copies directories and files.
- EnumerateDirectoryMatches - evaluates glob patterns against directories.
- EnumerateFileMatches - evaluates glob patterns against files.
- EnumerateFileSystemInfoMatches - evaluates glob patterns against directories.
- EnsureDirectory - creates a directory if it doesn't exist.
- EnsureFile - creates a file it doesn't exist.
- Match - evaluates a glob for matches.
Ps
The Ps class invokes child processes and has helper methods such as Which
that
determines if an executable is on the path.
using GnomeStack.Standard;
// elsewhere
// executes and sends out standard out and standard error.
Ps.Exec("dotnet", "--version");
Ps.Exec("dotnet", new[] { "build", "-c", "Configuration"});
// captures standard out and standard error.
var output = Ps.Capture("dotnet", "build -c 'Configuration'");
Console.Log(output);
Console.Log(output.ExitCode);
Console.Log(output.StdOut); // readonly list of string
Console.Log(Ps.Which("git"));
// use more of a builder pattern
var output2 = Ps.New("git")
.WithArgs("--version")
.WithStdOut(Stdio.Piped) // captures standard out
.WithCwd("/path/to/repo")
.Output()
.ThrowOnInvalidExitCode();
Console.Log(output2);
Console.Log(output2.ExitCode);
// chain command line calls
Ps.New("echo", "my test")
.Pipe("grep", "test")
.Pipe("cat")
.Output();
Env
Environment is an extended version of System.Environment.
- IsWindows
- IsLinux
- IsMacOS
- IsWsl
- Is64BitOs
- IsPrivilegedProcess
- ProcessArch
- OsArch
- Expand - Expand a template string with environment variables.
- Vars - A variable property that is enumerable and has index get and set access.
- Get - Gets an environment variable
- TryGet - Tries to get the environment variable.
- GetRequired - Gets the environment variable or throws.
- Set - Sets the environment variable.
- Has - Has the environment variable.
- Remove - Removes the environment variable.
- AddPath - Adds a path to the environment path variable.
- GetPath - Gets the path environment value.
- SetPath - Sets the path environment value;
- HasPath - Determines if a path already exists in the environment path variable.
- RemovePath - Removes a path from the environment path variable.
Environment.SetEnvironmentVariable("WORD", "World");
var result = Env.Expand("Hello %WORD%");
assert.Equal("Hello World", result);
var result2 = Env.Expand("Hello ${WORD}");
assert.Equal("Hello World", result2);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Bcl.HashCode (>= 1.1.1)
- Microsoft.Extensions.FileSystemGlobbing (>= 7.0.0)
- System.Memory (>= 4.5.5)
- System.Threading.Tasks.Extensions (>= 4.5.4)
-
net6.0
- Microsoft.Extensions.FileSystemGlobbing (>= 7.0.0)
-
net7.0
- Microsoft.Extensions.FileSystemGlobbing (>= 7.0.0)
NuGet packages (15)
Showing the top 5 NuGet packages that depend on GnomeStack.Core:
Package | Downloads |
---|---|
GnomeStack.Text.Yaml
GnomeStack.Text.Yaml |
|
GnomeStack.Text.Json
GnomeStack.Text.Json |
|
GnomeStack.Security.Cryptography
A cryptography library for GnomeStackFx to help with encryption for automation purposes. |
|
GnomeStack.Extensions.Secrets.Abstractions
Provides abstractions for secret vaults to enable switching out vaults in an application and provides a default null provider. |
|
GnomeStack.Text.DotEnv
DotEnv library for .NET that includes expanding variables and does not use regex. |
GitHub repositories
This package is not used by any popular GitHub repositories.
# CHANGE LOG
## 0.1.2
- Move Color and Ansi namespaces to Fmt.Ansi and Fmt.Color.
- Fix Rgb methods on Standard.Ansi to applying Ansi codes to text when Ansi
Mode is none like the rest of the Ansi methods.
- Add Map and MapError to Result module.
- Changes Result.ThrowIfError to return result instead of unwrapping
the value.
- Changed PsCommand to be more of a builder pattern or allows to
the implementation of PsArgs and executable to be changed.
- Added PsCommand to various Ps methods to make it easier to pass in
objects that represent cli commands to be executed.
- Added ResourcePath class to help with common use case of strings
that use '/', ':', or '.' as separator to navigate hierarchical
objects or data.
## 0.1.1
- Add Symbol struct for js/ruby like symbols of interned strings.
- Add Fs.ChangeOwner function to (chown) change the owner of a file.
- Add Fs.ChangeMode function to (chmod) change the mode of a file.
- Add Diagnostics.PsPathRegistry to store executable paths and
and fallback paths to search for executables for different platforms.
- Useful for post installation of executables.
- Useful for common install locations for user folders or system folders.
- Useful for overriding the default location for an executable through
environment variables or lookup paths.
## 0.1.0 initial creation