0

I don´t get a help - Output into my cmd.

Based on my last question ( How to integrate c# help into console application ) I want integrate a help function into my c# written application.

I already integrated the help function code but i think that ist not completly.

Here my code:

namespace Application1
{
    static class Program
    {
        // Implementation
        static bool ShowHelpRequired(IEnumerable<string> args) // help function II
        {
            return args.Select(s => s.ToLowerInvariant())
                .Intersect(new[] { "help", "/?", "--help", "-help", "-h" }).Any();
        }

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

            if (ShowHelpRequired(args))
            {
                Console.WriteLine("Show help message here");
            }

       }

    }
}

Could someone give me a example how to get an(help) Output into my cmd?

My Case: Actually if i call my "GUI.exe" into the cmd with -> "GUI.exe -h", then only my "GUI.exe" will be started.

My Goal:

If i cmd and enter -> "GUI.exe -h" then the it should Comes an Output with help information about my GUI.exe

It would be great if someone could Support my to reach my Goal.

In Advance thank you very much.

Moha86B
  • 1
  • 3
  • Well, what is the question? Put your help text into the messagebox? Please be aware that if your application is not a console application, it's not easy to get output into a console that the application was started from. Many programs just default to a window with the help text in this case, or popping up a help file. – Lasse V. Karlsen Aug 28 '17 at 06:15
  • @ Lasse V. Karlsen, thx for your fast answer. i want to get a help list Output into my cmd. For example i want to start the help function from my "GUI.exe" via cmd with => "GUI.exe -h" if i enter that, then it should be listet a help list into my cmd. Actually i don´t get a help list into my cmd if i enter "GUI.exe -h". – Moha86B Aug 28 '17 at 06:16
  • Then, unfortunately, you're going to have to make your GUI.exe a console application, which means that it'll pop up a console window when started without the `-h` option. If you do this then it's just a matter of using `Console.WriteLine` to output your help text. – Lasse V. Karlsen Aug 28 '17 at 06:23
  • If you can live with your GUI program popping up a console *briefly* during startup then you can check this question [here](https://stackoverflow.com/questions/1786840/c-is-it-possible-to-have-a-single-application-behave-as-console-or-windows-app) for a way to have it behave like this. – Lasse V. Karlsen Aug 28 '17 at 06:25
  • Welcome to stackoverflow, you might want to read https://stackoverflow.com/help/how-to-ask for your next questions. You should know that the beginning of your question is what we see in the question list, so you want to avoid starting with "good morning, I hope you can help me" as it doesn't say anything about your problem even if it is nice to people ;) – Rafalon Aug 28 '17 at 06:49
  • @ Rafalon, edited my text. @Lasse V. Karlsen is your solution the only option to get an Output into my cmd? – Moha86B Aug 28 '17 at 07:03
  • When you say "my cmd", do you mean: I open up a command prompt, and run `GUI -h` and I want the output in the same console window? If the answer is yes, then that is the only answer I know of, yes. – Lasse V. Karlsen Aug 28 '17 at 07:18
  • @ Lasse V. Karlsen with "my cmd" i mean the Standard "cmd.exe"-from Windows. – Moha86B Aug 28 '17 at 07:27

0 Answers0