Sage.Tools.Program.ShowUsage C# (CSharp) Method

ShowUsage() private static method

private static ShowUsage ( string programName = null ) : int
programName string
return int
        private static int ShowUsage(string programName = null)
        {
            StringBuilder usage = new StringBuilder();
            if (programName != null && utilities.ContainsKey(programName))
            {
                IUtility utility = utilities[programName];
                usage.AppendLine(utility.GetUsage());
            }
            else
            {
                if (programName != null)
                {
                    usage.AppendLine(string.Format("'{0}' is an unknown command.", programName));
                }
                else
                {
                    usage.AppendLine("Sage.Tools");
                    usage.AppendLine("Command-line utilities for working with Sage projects and extensions.");
                }

                usage.AppendLine("The available commands are:");
                foreach (string command in utilities.Keys)
                    usage.AppendFormat("  - {0}\n", command);

                usage.AppendLine();
                usage.AppendFormat("Type {0} help <command> to get more information about that command.\n", Program.Name);
            }

            Console.Write(usage.ToString());
            return 1;
        }