<commit_before>/*
 * Source MUD
 * Copyright (C) 2000-2005  <NAME>
 * See the file COPYING for license details
 * http://www.sourcemud.org
 */

#include "common/string.h"
#include "mud/player.h"
#include "mud/command.h"
#include "mud/settings.h"
#include "common/streams.h"
#include "mud/color.h"
#include "mud/fileobj.h"
#include "mud/macro.h"
#include "mud/help.h"
#include "mud/telnet.h"
#include "common/manifest.h"

#include <iostream>

SHelpManager HelpManager;

void command_help (Player* player, String argv[])
{
	StreamControl stream(player);
	HelpManager.print (stream, argv[0]);
}

HelpTopic*
SHelpManager::get_topic (String name)
{
	for (TopicList::iterator i = topics.begin(); i != topics.end(); ++i)
		if (phrase_match((*i)->name, name))
			return *i;
	return NULL;
}

void
SHelpManager::print (StreamControl& stream, String name)
{
	// try a man page
	if (!name.empty() && CommandManager.show_man(stream, name, true))
		return;

	// try a help topic
	HelpTopic* topic = name.empty() ? get_topic(S("general")) : get_topic(name);
	if (topic) {
		stream << CSPECIAL "Help: " CNORMAL << topic->name << "\n\n";
		stream << StreamIndent(2) << StreamMacro(topic->about) << StreamIndent(0) << "\n";
		return;
	}

	// nope, nothin'
	stream << CSPECIAL "No help for '" << name << "' available." CNORMAL "\n";
}

int
SHelpManager::initialize ()
{
	ManifestFile man(SettingsManager.get_help_path(), S(".help"));
	StringList files = man.get_files();;
	for (StringList::iterator i = files.begin(); i != files.end(); ++i) {
		File::Reader reader;<commit_msg>use file list instead of Manifest for help<commit_after>/*
 * Source MUD
 * Copyright (C) 2000-2005  <NAME>
 * See the file COPYING for license details
 * http://www.sourcemud.org
 */

#include "common/string.h"
#include "mud/player.h"
#include "mud/command.h"
#include "mud/settings.h"
#include "common/streams.h"
#include "mud/color.h"
#include "mud/fileobj.h"
#include "mud/macro.h"
#include "mud/help.h"
#include "mud/telnet.h"
#include "common/file.h"

#include <iostream>

SHelpManager HelpManager;

void command_help (Player* player, String argv[])
{
	StreamControl stream(player);
	HelpManager.print (stream, argv[0]);
}

HelpTopic*
SHelpManager::get_topic (String name)
{
	for (TopicList::iterator i = topics.begin(); i != topics.end(); ++i)
		if (phrase_match((*i)->name, name))
			return *i;
	return NULL;
}

void
SHelpManager::print (StreamControl& stream, String name)
{
	// try a man page
	if (!name.empty() && CommandManager.show_man(stream, name, true))
		return;

	// try a help topic
	HelpTopic* topic = name.empty() ? get_topic(S("general")) : get_topic(name);
	if (topic) {
		stream << CSPECIAL "Help: " CNORMAL << topic->name << "\n\n";
		stream << StreamIndent(2) << StreamMacro(topic->about) << StreamIndent(0) << "\n";
		return;
	}

	// nope, nothin'
	stream << CSPECIAL "No help for '" << name << "' available." CNORMAL "\n";
}

int
SHelpManager::initialize ()
{
	StringList files = file::getFileList(SettingsManager.get_help_path(),
			S(".help"));
	for (StringList::iterator i = files.begin(); i != files.end(); ++i) {
		File::Reader reader;
{'fraction_non_alphanumeric': 0.1801023672424824, 'fraction_numerical': 0.007037747920665387, 'mean_word_length': 4.59391771019678, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3255437', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1109, 'n_words': 278}