'How to write a program with commands?

I would like to write a program that will handle commands like

add: And asks for your first name, surname, age list: List the people in a directory remove: removes detail: Displays the details of the person open: opens a file. (from json and xml) save: save the file (in json and xml)

I am at this stage so far

and my question is as follows .... the code below is File and it doesn't have options like remove or detail, add

I need hints such as what method, link, etc. I will be grateful

string path2 = @"logowanie6.txt";
        Console.WriteLine("Hej! Przedstaw się. Twoje dane będą zapisane w pliku o nazwie logowanie6.txt");

        if (!File.Exists(path2))
        {

            using (StreamWriter sw = File.CreateText(path2))
            {
                sw.WriteLine("Osoby, które logowały się: ");

            }
        }


        using (StreamWriter sw = File.AppendText(path2))
        {
            string namesurname = Console.ReadLine();
            sw.WriteLine(namesurname);

        }
        using (StreamReader sr = File.OpenText(path2))
        {
            string s = "";
            while ((s = sr.ReadLine()) != null)
            {
                Console.WriteLine(s);
            }
        }

After couple hours i made something like this.... Can someone tell me next hint?

class Person
    {
    public int Id { get; set; }
    public string Name { get; set; }
    }

    class FileExample
    {
        static void Main(string[] args)
        {

            while (true)
            {
                string choice = Console.ReadLine();
                switch (choice)
                {
                    case "Add":
                        break;
                    case "Update":
                        break;
                    case "Remove":
                        break;
                    case "Exit":
                        return;
                }
            }
        }

        static List<Person> LoadList()
        {
            string text = File.ReadAllText("persons.txt");
            if (string.IsNullOrEmpty(text))
                return new List<Person>() { };
            return JsonConvert.DeserializeObject<Person[]>(text).ToList();
        }
        static void SaveList(IEnumerable<Person> persons)
        {
            File.WriteAllText("persons.txt", JsonConvert.SerializeObject(persons.ToArray()));
        }
        static void AddPerson(List<Person> list, Person newPerson)
        {
            list.Add(newPerson);
        }
        static void RemovePerson(List<Person> list, int personId)
        {
            var foundPerson = list.FirstOrDefault(x => x.Id == personId);
            if (foundPerson != null)
                list.Remove(foundPerson);
        }
    }
        


Solution 1:[1]

Maybe try this: https://github.com/commandlineparser/commandline

Just create multiple verbs like: list, add, remove, change, makeFun etc and instead handle them in one process, just call EXE from command line with different operations

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wojciech Gebczyk