/// <summary>
        /// Generates usage information for a terminal
        /// </summary>
        public static string HelpOn(ITerminal terminal)
        {         //****************************************
            var  HasCommands  = false;
            var  HasVariables = false;
            var  HasTypes     = false;
            var  Builder      = new StringBuilder();
            bool IsFirst;

            //****************************************

            foreach (var Registry in terminal.Registries)
            {
                HasCommands  |= Registry.Commands.Count > 0;
                HasVariables |= Registry.Variables.Count > 0;
                HasTypes     |= Registry.TypeSets.Count > 0;
            }

            if (HasCommands)
            {
                Builder.AppendLine("Available Commands:").Append("  ");

                IsFirst = true;

                foreach (var Command in
                         terminal.Registries.SelectMany(registry => registry.Commands)
                         .Concat(terminal.Registries.SelectMany(registry => registry.DefaultInstances).SelectMany(instance => instance.Type.Commands))
                         .OrderBy(command => command)
                         )
                {
                    if (IsFirst)
                    {
                        IsFirst = false;
                    }
                    else
                    {
                        Builder.Append(", ");
                    }

                    Builder.Append(Command.ToString());
                }
            }

            if (HasVariables)
            {
                if (Builder.Length > 0)
                {
                    Builder.AppendLine();
                }

                Builder.AppendLine("Available Variables:").Append("  ");

                IsFirst = true;

                foreach (var Variable in
                         terminal.Registries.SelectMany(registry => registry.Variables)
                         .Concat(terminal.Registries.SelectMany(registry => registry.DefaultInstances).SelectMany(instance => instance.Type.Variables))
                         .OrderBy(variable => variable))
                {
                    if (IsFirst)
                    {
                        IsFirst = false;
                    }
                    else
                    {
                        Builder.Append(", ");
                    }

                    Builder.Append(Variable.ToString());
                }
            }

            if (HasTypes)
            {
                if (Builder.Length > 0)
                {
                    Builder.AppendLine();
                }

                Builder.AppendLine("Available Types:").Append("  ");

                IsFirst = true;

                foreach (var TypeSet in terminal.Registries.SelectMany(registry => registry.TypeSets).Where(type => type.HasInstance).OrderBy(type => type))
                {
                    if (IsFirst)
                    {
                        IsFirst = false;
                    }
                    else
                    {
                        Builder.Append(", ");
                    }

                    Builder.Append(TypeSet.ToString());
                }
            }

            return(Builder.ToString());
        }