CliSquid 0.1.0-alpha.4

This is a prerelease version of CliSquid.
dotnet add package CliSquid --version 0.1.0-alpha.4                
NuGet\Install-Package CliSquid -Version 0.1.0-alpha.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CliSquid" Version="0.1.0-alpha.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CliSquid --version 0.1.0-alpha.4                
#r "nuget: CliSquid, 0.1.0-alpha.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CliSquid as a Cake Addin
#addin nuget:?package=CliSquid&version=0.1.0-alpha.4&prerelease

// Install CliSquid as a Cake Tool
#tool nuget:?package=CliSquid&version=0.1.0-alpha.4&prerelease                

CliSquid

Fancy prompts for dotnet console applications. Heavily "inspired" by Clack and Bubbles

VERY EARLY RELEASE USE AT YOUR OWN PERIL!!

Installation

NuGet package is hosted on NuGet and can be installed from your package manager

PM> Install-Package CliSquid --prerelease

or from the dotnet cli

> dotnet add package CliSquid --prerelease

Usage

Configure the library, currently this is where you could set theme options and other settings in the future

using CliSquid;
using CliSquid.Enums;
using CliSquid.Themes;

Prompt.Configure(options =>
{
    options.Theme = Theme.GetTheme(PromptTheme.Default);
});
Prompts
Intro - informational prompt with some styling, bit like an app header

Prompt.Intro("my-app-name");

UserInput - capture text input from the user

// text
var name = Prompt
    .FromUserInput<string>()
    .Title("What is your name?")
    .Placeholder("Ezekiel")
    .Validate(
        (string x) =>
        {
            if (x == "Tony" || x == "Ezekiel")
                return Tuple.Create(true, string.Empty);
            else
                return Tuple.Create(false, "You can only be Tony or Ezekiel");
        }
    )
    .Read();

var name2 = Prompt
    .FromUserInput<string>()
    .Title("What is your name?")
    .Placeholder("Tony")
    .Validate(
        (string x) =>
        {
            if (x.Equals(name, StringComparison.OrdinalIgnoreCase))
                return Tuple.Create(false, string.Format("You can't both be {0}", x));
            else if (x == "Tony" || x == "Ezekiel")
                return Tuple.Create(true, string.Empty);
            else
                return Tuple.Create(false, "You can only be Ezekiel or Tony");
        }
    )
    .Read();

Input validtation returns a Tuple<bool, string> to represent the valid status and any error message that might be required in the console.

Select list

From Enum:


public enum NotificationStatus
{
    Scheduled,
    InProgress,
    Complete,
    RolledBack
}

var status = Prompt
		.FromEnum<NotificationStatus>()
		.Title("Notification status")
		.SelectOne();

Single value from custom list:


var options = new List<PromptOption<string>>()
{
    new PromptOption<string>("Hello") { Display = "Hi!" },
    new PromptOption<string>("Goodbye") { Hint = "not hello", IsDefault = true }
};
var greeting = Prompt.FromList<string>().Title("Select one").Options(options).SelectOne();

Multiple values from custom list:

var tech = new List<string> { "Typescript", "Tailwind", "React", "dotnet", "Vuejs" };
var techOptions = tech.Select(t => new PromptOption<string>(t)).ToList();
techOptions[1].IsDefault = true;
techOptions[1].Hint = "[recommended]";
techOptions[2].IsDefault = true;
techOptions[2].Hint = "[recommended]";

var selectedTech = Prompt
    .FromList<string>()
    .Title("Choose your tech stack")
    .Options(techOptions)
    .SelectMany();

or optionally as an inline list:

var selectedTech = Prompt
    .FromList<string>()
    .Inline()
    .Title("Choose your tech stack")
    .Options(techOptions)
    .SelectMany();
Spinner

Show an 'animated' cursor while performing other actions (TODO: Async version)

var result = Prompt
    .Spinner<string>()
    .Title("Perfoming complicated stuff")
    .SetSpinnerType(SpinnerType.Dots)
    .Spin(p =>
    {
        p.SetStatus("Starting...");
        for (var i = 0; i < 2; i++)
        {
            p.SetStatus(string.Format("Processing... {0}", i));
            Task.Delay(2000).ConfigureAwait(false).GetAwaiter().GetResult();
        }

        p.SetStatus("Completed..");
        return "Finished doing something time consuming...";
    });
Confirm returns true/false
var confirm = Prompt.Confirm("Are you sure?");
Complete

Used at the end of the application flow

Prompt.Complete("Fuck you, Tony!");
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0-alpha.4 184 11/15/2023
0.1.0-alpha.3 61 11/15/2023
0.1.0-alpha.2 63 11/15/2023
0.1.0-alpha.1 70 11/14/2023