ConsoleMenuApp 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package ConsoleMenuApp --version 1.0.0                
NuGet\Install-Package ConsoleMenuApp -Version 1.0.0                
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="ConsoleMenuApp" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ConsoleMenuApp --version 1.0.0                
#r "nuget: ConsoleMenuApp, 1.0.0"                
#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 ConsoleMenuApp as a Cake Addin
#addin nuget:?package=ConsoleMenuApp&version=1.0.0

// Install ConsoleMenuApp as a Cake Tool
#tool nuget:?package=ConsoleMenuApp&version=1.0.0                

🖥️ ConsoleMenu 🖥️

ConsoleMenu is a 🚀 powerful and flexible library for creating console-based menus in .NET. It allows you to easily create 🎛️ interactive menus for your console applications.

🌟 Features 🌟

  • 📜 Create menus with multiple options.
  • 🚀 Navigate through different submenus.
  • 🎯 Perform actions based on user's selection.
  • 📂 Navigate through directories in the file system.

📝 Example 📝

Here's an example of how you can use ConsoleMenu to create a menu for managing a list of students:

using ConsoleMenu;
using ConsoleMenu.Models;

var students = new List<string>();

void AddStudent()
{
    Console.WriteLine("Enter student name:");
    var studentName = Console.ReadLine();
    if(string.IsNullOrWhiteSpace(studentName))
    {
        Console.WriteLine("Student name cannot be empty");
        return;
    }
    students.Add(studentName);
    Console.WriteLine($"Student {studentName} added.");
}

void EditStudent()
{
    Console.WriteLine("Enter student name to edit:");
    var studentName = Console.ReadLine();
    var index = students.IndexOf(studentName);
    if (index != -1)
    {
        Console.WriteLine("Enter new name:");
        var newName = Console.ReadLine();
        students[index] = newName;
        Console.WriteLine($"Student {studentName} edited to {newName}.");
    }
    else
    {
        Console.WriteLine($"Student {studentName} not found.");
    }
}

void DeleteStudent()
{
    Console.WriteLine("Enter student name to delete:");
    var studentName = Console.ReadLine();
    string? studentResult = students.FirstOrDefault(student => student == studentName);
    if (studentResult == null)
    {
        Console.WriteLine($"Student not found");
        return;
    }
    students.Remove(studentResult);
    Console.WriteLine($"Student {studentName} deleted.");
}

void ListStudents()
{
    Console.WriteLine("Listing students:");
    foreach (var student in students)
    {
        Console.WriteLine(student);
    }
}

void SearchStudent()
{
    Console.WriteLine("Enter student name to search:");
    var studentName = Console.ReadLine();
    if (students.Contains(studentName))
    {
        Console.WriteLine($"Student {studentName} found.");
    }
    else
    {
        Console.WriteLine($"Student {studentName} not found.");
    }
}

var studentMenu = ConsoleItem.CreateSubMenu("Students menu", new()
{
    ConsoleItem.CreateSpecialItem("Add student", AddStudent),
    ConsoleItem.CreateSpecialItem("Edit student", EditStudent),
    ConsoleItem.CreateSpecialItem("Delete student", DeleteStudent),
    ConsoleItem.CreateSpecialItem("List students", ListStudents),
    ConsoleItem.CreateSpecialItem("Search student", SearchStudent),
});

string? desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
var menu = new ConsoleMenuApp("Main Menu")
    .AddItem(studentMenu)
    .AddGetFolderOption("Get students folder", desktopPath)
    .AddItem(ConsoleMenuApp.DefaultOptions.ClearConsole("Clear console"))
    .AddItem(ConsoleMenuApp.DefaultOptions.Exit("Exit"));


menu.Open();

In this example, a ConsoleMenuApp is created with a submenu for managing students and an option for selecting a directory from the file system. The AddStudent method is used to add a new student to the list of students. Other student operations can be implemented in a similar way.

🚀 Getting Started 🚀

To get started with ConsoleMenu, you can clone this repository and check out the ConsoleMenu.Test project, which contains a comprehensive example of how to use the library.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ConsoleMenuApp:

Package Downloads
ConsoleMenuApp.Reflection

A extension to the ConsoleMenuApp nuget using reflection

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 118 6/9/2024
1.0.0 100 6/8/2024